0
I have a method that opens a CSV file but would like to go straight into a specific column, I tried to do it this way list2 = [row.split()[3] for row in f]
, but returns a piece of the file and not the column. Is it possible to do this without using PANDAS?
My method:
import csv
list2 = []
count = 0
with open('meuarquivo.csv') as f:
list2 = [row.split()[3] for row in f]
while(count <= 20):
print(list2[count])
count+=1
Are the columns separated by a comma? If so, use
row.split(',')
.split
no parameters separated by spaces.– gabrieloliveira