Xlsx Writer getting corrupted with Strings
<p>I am currently exporting a dataframe to an excel spreadsheet, but my one of my columns which has long strings with varying lengths cause the file to get corrupted. </p>

<pre><code>with pd.ExcelWriter('thing.xlsx'.format(path), engine='xlsxwriter',options={'strings_to_urls': False}) as writer:
</code></pre>

<p>Here I make put it into excel</p>

<pre><code>df.to_excel(writer, 'long_text', index=False)
</code></pre>

<p><strong>Edit</strong> </p>

<p>When I remove that column from the dataframe it ceases to corrupt, but I want to keep the column. When I limit the characters to 37 characters it also ceases to be corrupted. Which suggests that there is a character that is having trouble being encoded.</p>

<p>Any ideas as to how to handle this? </p>

<p>as @jmcnamara remarked my issue was that one of my strings was not encoded in UTF-8, but after encoding all the strings the excel file ceased to be corrupted</p>

python pandas dataframe xlsxwriter