Jul-04-2017, 06:45 AM
Dear wavic, I am thankful for the code you provided above. It worked fine for me during tests in the following form:
with open('file.csv', 'r') as in_file: #note it's a CSV while in_file.readline().split()[0] != 'FIPS': pass # write the rest in separed files for line in in_file.readline(): with open('{}.txt'.format(line.slit()[0]), 'w') as out_file: out_file.write(line)However, for some reason today it resulted in the following error:
Error:---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-61-11e3906ccb41> in <module>()
1 #pass all lines untils 'fips txt'
2 with open('TW_13.csv', 'r') as in_file:
----> 3 while in_file.readline().split()[0] != 'FIPS':
4 pass
5
IndexError: list index out of range
The csv looks like this:FIPS text 0 1001 I screwed that last tweet upAnd im ready to get... 1 1003 Like, please, we're all dying to know how many... 2 1005 ": å???: I haven't felt this good in a while ?... 3 1007 I always do ya favored. That's romance no hope... 4 1009 ???????????????? never heard it put that way... ... ... ... 3224 72153 Good morning gangstass :O å??å« Just is... PE... 3225 78010 lol, I know but I hear it has a dance??She do... 3226 78020 it's on a camera other than an iPhoneeeee14, ... 3227 78030 I'm gonna meet BeyoncÌ?å© after the show or im... 3228 rows × 2 columnsCould you please help me out with this. Thankfully, kiton