You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "betodealmeida (via GitHub)" <gi...@apache.org> on 2023/02/27 20:06:15 UTC
[GitHub] [superset] betodealmeida commented on a diff in pull request #23155: fix :Extra column in csv while sending csv on email
betodealmeida commented on code in PR #23155:
URL: https://github.com/apache/superset/pull/23155#discussion_r1119254393
##########
superset/config.py:
##########
@@ -748,6 +748,10 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
# note: index option should not be overridden
CSV_EXPORT = {"encoding": "utf-8"}
+#It Is used for enable/disable the index sequence for csv which came at email-time,
+#rearly someone want the index in csv so by-default it is false
+CSV_INDEX={"index":False}
+
Review Comment:
Let's keep the current behavior as the default, even if it's weird. We can change the default in 3.0:
```suggestion
# Show the dataframe index when emailing a CSV report
CSV_INDEX = True
```
Also, let's make this a boolean so it's less error-prone.
##########
superset/charts/post_processing.py:
##########
@@ -39,6 +39,11 @@
get_column_names,
get_metric_names,
)
+from superset import (
+ app
+)
+
+config = app.config
Review Comment:
It's better to use `current_app`:
```suggestion
from flask import current_app
config = current_app.config
```
##########
superset/charts/post_processing.py:
##########
@@ -368,7 +373,7 @@ def apply_post_process(
query["data"] = processed_df.to_dict()
elif query["result_format"] == ChartDataResultFormat.CSV:
buf = StringIO()
- processed_df.to_csv(buf)
+ processed_df.to_csv(buf, **config["CSV_INDEX"])
Review Comment:
See my comment below in `superset/config.py`.
```suggestion
processed_df.to_csv(buf, index=config["CSV_INDEX"])
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org