Created
December 19, 2013 18:31
-
-
Save mrmch/8043933 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fname = 'NAICS.txt' | |
ofname = 'NAICS_FIXED.txt' | |
with open(fname, 'r') as ifile: | |
with open(ofname, 'w') as ofile: | |
for line in ifile.readline(): | |
parts = line.split(":") | |
if len(parts) > 2: | |
# we have a partial | |
next_line = ifile.readline() | |
new_line = '"%s":"%s"' % (line, next_line) | |
ofile.writeline(new_line) | |
else: | |
ofile.writeline(line) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, Matt.
This is actually what I was looking to build.
Cheers!