Как создать список из CSV Python
import csv
with open('file.csv', newline='') as f:
reader = csv.reader(f)
data = list(reader)
print(data)
Gubo97000
import csv
with open('file.csv', newline='') as f:
reader = csv.reader(f)
data = list(reader)
print(data)
# Convert a list into rows for a column in csv
import csv
for_example = [1, 2, 3, 4, 5, 6]
with open('output.csv', 'w', newline='') as csv_1:
csv_out = csv.writer(csv_1)
csv_out.writerows([for_example[index]] for index in range(0, len(for_example)))
import pandas as pd
list1 = [1,2,3,4,5]
df = pd.DataFrame(list1)
df.to_csv('test.csv') ##It will include index also
df.to_csv('test.csv', index=False) #Without Index