I have a small script that extracts data from a csv file. the file is unorganised and I have about 1000 of them to get the data from so far so I can't simply edit the format. I created a script the reads each line one by one skipping all the useless data then reading whats left, I needed to remove the first 36 characters and the last 3. However this prints inacurate data for some reason
My Code
import sys
import time
from sys import argv
while True:
argv1 = "ex.csv"
script, filename = argv, argv1
f = open(filename, 'r')
for i, line in enumerate(f):
print (line)[36::3]
print (i)
time.sleep(5)
My first 2 lines of data are pretty empty so ignoring those here is the next line from ex.csv
20/03/2015 10:28:26, 390114.322299, 393732.492744, 0
Using the above code when printing (line) I get the data 37.240
I do not understand where it is getting this number from. as far as I understand from what I have been learning its suppose to skip [start:middle:end]
so it should skip 36 from the start and 3 from the end and non in the middle.
Also not all ranges of data are set at 11 characters so I can't skip all but 11 characters either.