Skip to content

Instantly share code, notes, and snippets.

@letroot
Last active February 12, 2018 09:44
Show Gist options
  • Save letroot/b282fd1c8aab129f3cf77ddab93dec03 to your computer and use it in GitHub Desktop.
Save letroot/b282fd1c8aab129f3cf77ddab93dec03 to your computer and use it in GitHub Desktop.
SOURCE_FILE = "data.txt"
DEST_FILE = "out.txt"
def stringify(s):
return('\"{}\"'.format(s.strip()))
def stringify_ls(string_ls):
return ','.join(list(map(stringify, string_ls.split(','))))
def stringify_file(source_file, dest_file):
with open(source_file) as sourcefile:
with open(dest_file, "w") as destfile:
# skip header line
header = next(sourcefile)
destfile.write(header)
for line in sourcefile:
destfile.write(stringify_ls(line))
destfile.write("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment