Monday, April 16, 2012

analyzing a txt file in python by jumping the n_th element of a list

I have trouble handling a txt file with lines like this:



50.0 0.1 [0.03, 0.05, 0.067, 1.003, ...]
50.0 0.134 [0.3465, 0.5476, 1.0, ....]
.
.
.


I don't need the beginning of each line, just the lists!The elements of a list are not evenly spaced and seperated by space characters and comma.
What i wanna do is ignore what ever is in front of the list, jump to (for example) the 9th element of the list, read and save it und then go to the next line and do the same.



my approach:



Find away way to handle the line oft the txt as a list and not as a string, so i can operate with the elements of the list..



or



manage to jump to the 9th space character and then read everythin till the next (10th in this case) space character



any ideas how to do this?



Every idea for a solution is appreciated! thx





No comments:

Post a Comment