You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @Afsalmc! 👋 I'm here to help you with any bugs, questions, or contributions you have while waiting for a human maintainer. Let's squash those bugs together!
To resolve the issue where downloading query results to CSV fails with the error _csv.Error: need to escape, but no escapechar set when the values contain null characters, you need to set the escapechar parameter in the CSVReader configuration.
Here is an example of how you can modify the CSVReader configuration to include the escapechar:
This sets the escape character to a backslash (\), which will handle the null characters properly during the CSV export.
Additionally, you can use the df_to_escaped_csv function from the superset/utils/csv.py module to ensure that special characters are properly escaped in your DataFrame before exporting it to CSV:
importpandasaspdfromsuperset.utils.csvimportdf_to_escaped_csv# Assuming df is your DataFramecsv_data=df_to_escaped_csv(df)
withopen('output.csv', 'w') asfile:
file.write(csv_data)
This function will escape problematic characters and set the escape character to a backslash (\), ensuring that the CSV export handles null characters and other special cases correctly [1][2].
We can control what escape characters should be set while exporting pandas Dataframe through a superset config. By default we are not setting any escape character, only the encoding to use is set. CSV_EXPORT = {"encoding": "utf-8"}
We can modify this config to specify an escape character,
Bug description
If the Query result contains null characters Exporting to CSV fails. Getting error logs:
_csv.Error: need to escape, but no escapechar set
How to reproduce the bug
Screenshots/recordings
No response
Superset version
4.0.1
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: