I'm working on lists that I want to export into an Excel file.
I found a lot of people advising to use pandas.dataframe so that's what I did. I could create the dataframe but when I try to export it to Excel, the file is empty, there is just the following message:
" Error! [file_pathway] is not UTF-8 encoded. Saving disabled. See console for more details".
I didn't see any more info on the console, and every example I found on the Internet leads to the same error message.
The different lists I'm using contain different types of data. So I try to convert every element I could into a UTF-8 encoded element. I couldn't do it for the "float" list nor for the "NoType" list.
After that, here is what I wrote :
d = {'Dataset_name': dataset_names, 'Parameter_name': para_names, 'Parameter_amount': para_amounts, 'Parameter_unit': para_units, 'Parameter_variable': para_variables, 'Parameter_formula': para_formulas}
df = pd.DataFrame(data=d)
from pandas import ExcelWriter
writer = ExcelWriter('Ocelot_Export.xlsx')
df.to_excel(writer, encoding='utf8', index=False)
writer.save()
The dataframe is correct, as I can print it in Jupyter Notebook. The only problem is the exportation. Please let me know if you have any idea about what's wrong.
This error is created when the uploaded file is not in a UTF-8 format. UTF-8 is the dominant character encoding format on the World Wide Web. This error occurs because the software you are using saves the file in a different type of encoding, such as ISO-8859, instead of UTF-8.
How to write a pandas DataFrame to CSV file. Delimit by a tab you can use the sep argument . Avoid index column use index argument . Use a specific encoding (e.g. 'utf-8' ) use the encoding argument .
The cause of this problem is likely just that jupyter is unable to display .xlsx
files. Try downloading the file from jupyter (checkbox next to the file name -> "Download" button near the page header) onto your local machine and open it using excel.
2020 Update: If you're using Jupyter Lab, jupyterlab-spreadsheet is a great way to view excel files without leaving your browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With