Dec-27-2018, 07:07 AM
What is desired result?
First word in line is 9 characters (except in line 9 where it's 10)
- Why create so many variables if you need only one?
- Why iterate over all lines in file and retain only last row status (every iteration of for-loop overwrites value of check and you will have it only for last row)?.
- What do you mean by "9 character string becomes 19 character due to added spaces when code reads it from the file"?
First word in line is 9 characters (except in line 9 where it's 10)
with open('data_log.txt', 'r', encoding='UTF-8') as f: for line in f: value = line.split()[0] print(len(value)) 9 9 9 9 9 9 9 9 10 9 9
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.