Skip to content

Instantly share code, notes, and snippets.

@mrmch
Created December 19, 2013 18:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrmch/8043933 to your computer and use it in GitHub Desktop.
Save mrmch/8043933 to your computer and use it in GitHub Desktop.
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)
@brianbancroft
Copy link

Thanks, Matt.

This is actually what I was looking to build.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment