I\'m trying to write a list of strings like below to a file separated by the given delimiter.
res = [u\'123\', u\'hello world\']
When I try
What worked for me was using a regular writer, not the csv.writer, and simply use your delimiter in between columns ('\t' in my case):
with open(target_path, 'w', encoding='utf-8') as fd:
# some code iterating over a pandas daftaframe called mydf
# create a string out of column 0, '\t' (tab delimiter) and column 1:
output = mydf.loc[i][0] + '\t' + mydf.loc[i][1] +'\n'
# write that output string (line) to the file in every iteration
fd.write(output)
It might not be the "correct" way but it definitely kept the original lines in my project, which included many strings and quotations.