Assuming the CSV file is delimited with commas, the simplest way using the csv
module in Python 3 would probably be:
import csvwith open('testfile.csv', newline='') as csvfile: data = list(csv.reader(csvfile))print(data)
You can specify other delimiters, such as tab characters, by specifying them when creating the csv.reader
, also adding skipinitialspace=True
to csv.reader
call if there are multiple space symbols between columns:
data = list(csv.reader(csvfile, delimiter='\t'))
For Python 2, use open('testfile.csv', 'rb')
to open the file.