I have the following CSV file:
name,A,B,C
name 1,2,8,3
name 2,4,1,5
name 3,3,2,5
I need to separate the lines read in CSV into an array, but If I insert the array index, it returns the column, and I need to separately manipulate the row and column. How did I do?
I need it:
[name,A,B,C]
[name 1,2,8,3]
[name 2,4,1,5]
[name 3,3,2,5]
print(array[0]) ## The result: [name,A,B,C]
print(array[0][1]) ## The result: A
My Code:
with open(csvFileName) as csv_file:
csv_reader = csv.reader(csv_file)
for row in csv_reader:
myList = list(row)
print(myList)
csv_file.close()
Terminal Result:
['name', 'Points', 'Maney', 'Coin']
['Client 1', '2', '8', '3']
['Client 2', '4', '1', '5']
['Client 3', '3', '2', '5']
Thank You
myList[1:] = list(map(int, myList[1:]))myListis only a single list containing only the current line instead of a list of lists of all the lines?