Last active
February 12, 2018 09:44
-
-
Save letroot/b282fd1c8aab129f3cf77ddab93dec03 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
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