0
votes

reading CSV files and concatenate files and then creating one single CSV file using data frame passed to pandas to_csv function below code shows

csv_buffer = StringIO()
data.to_csv(csv_buffer, index=False, encoding='utf-8')
s3_resource.Object(bucket, path_save_report+report_name).put(Body=csv_buffer.getvalue())

output CSV file

test123&quot       hello world
1

1 Answers

0
votes

I have solved this using a trick, actually, it's a problem with Linux Libre office application while reading the file, latest version gives this problem (Version: 6.0.7.3). The problem is while opening libre office application default uses column separated by ';'.

To solve this I have added escapechar parameter in to_csv (info) to ignore ; below updated code.

data.to_csv(csv_buffer, index=False, escapechar=';', encoding='utf-8')