1

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!!

0

1 Answer 1

1

Try this

log = [line.split(',') for line in open('log.csv')]
Sign up to request clarification or add additional context in comments.

1 Comment

Works perfect!! Thank you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.