Supose I have csv file named “liz.csv” which contains :
How can I import this file into lists using python?
Python has a built-in csv module, which provides a reader class to read the contents of a csv file.You can use that:
from csv import reader
with open('your file name.csv', 'r') as read_obj:
csv_reader = reader(read_obj)
list_of_rows = list(csv_reader)
You can also use pandas to read csv files without headers:
import pandas as pd
df = pd.read_csv('your file name.csv', delimiter=',')
list_of_rows = [list(row) for row in df.values]
Hope you understand now .
If not fell free to ask me any question.