I have a .csv file which contains data like the following example
A,B,C,D,E,F,
1,-1.978,7.676,7.676,7.676,0,
2,-2.028,6.081,6.081,6.081,1,
3,-1.991,6.142,6.142,6.142,1,
4,-1.990,65.210,65.210,65.210,5,
5,-2.018,8.212,8.212,8.212,5,
6,54.733,32.545,32.545,32.545,6,
..and so on
The format is constant.
I want to load the file in a variable "log" and access them as log[row][column]
example
log[0][2] should give C
log[3][1] should give -1
If use this code
file = open('log.csv')
log = list(file)
when i use this code i get only one dimensional. log[row]
Is their any way to directly store them?
for example
read the file
split with '\n'
split again with ','
Thanks!!
Try this
log = [line.split(',') for line in open('log.csv')]
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments