Skip to content Skip to sidebar Skip to footer

Importing .csv Values As Single List In Python

I have a csv file that has one column of records that looks like this: test1 test2 test3 ... I imported them into a Python list using this: import csv results = [] with open('tes

Solution 1:

Try the following code

import csv

results = []
with open('test.csv', newline='') as inputfile:
    for row in csv.reader(inputfile):
        results.append(row[0])

print(results)

Post a Comment for "Importing .csv Values As Single List In Python"