python csv to list code example
Example 1: read csv as list python
import csv
with open('file.csv', newline='') as f:
reader = csv.reader(f)
data = list(reader)
print(data)
Example 2: list to csv
import csv
with open("out.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerows(a)
Example 3: how to convert csv into list
open('file.csv', 'r').read().splitlines() #assuming you want each row to be an individual element in the list