Skip to content

Instantly share code, notes, and snippets.

@jorge-lavin
Created August 27, 2014 10:34
Show Gist options
  • Save jorge-lavin/f1210c459a9e68dd0bae to your computer and use it in GitHub Desktop.
Save jorge-lavin/f1210c459a9e68dd0bae to your computer and use it in GitHub Desktop.
def file_to_string(file_path):
"""
Converts a file into a string. \\t\\n join is used for format purposes in Outlook
"""
with open(file_path) as file_:
reader = csv.reader(file_, delimiter=';')
#If no delimiter is specified and are commas, ;, or other csv reader delimiters, this function may not
#work as expected. Therefore we force it to have ; because are not likely to be present
line = []
for lines in reader:
line.append(lines[0])
return '\t\n'.join(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment