I have a csv file like this and I want to take
A1,R,N,R,U,N,N,R,U,R,R
A2,R,U,R,R,N,N,R,N,N,N
B1,R,N,R,R,R,N,N,N,R,U
Now I want to get a list like this:
A1=[R,N,R,U,N,N,R,U,R,R]
A2=[R,U,R,R,N,N,R,N,N,N]
B1=[R,N,R,R,R,N,N,N,R,U]
how can I do that?
for x in range(len(a)): b = a[x].split(",") doc_line.append(b) for x in range(len(doc_line)): print(doc_line[x]) for x in doc_line: engine.append(x[0]) rel.append(x[1])
You can read row-wise from a csv file, below is the code for that.
from csv import reader with open('sample.csv', 'r') as csv_file: read_csv = reader(csv_file) for row in read_csv: print(row)
2.1m questions
2.1m answers
60 comments
57.0k users