Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve Column Order in Table CSV Export #10218

Closed
lilila opened this issue Jul 1, 2020 · 6 comments · Fixed by #10633
Closed

Preserve Column Order in Table CSV Export #10218

lilila opened this issue Jul 1, 2020 · 6 comments · Fixed by #10633
Labels
!deprecated-label:bug Deprecated label - Use #bug instead

Comments

@lilila
Copy link

lilila commented Jul 1, 2020

I am experiencing this new issue with superset 36.

I am pretty sure in the previous versions of superset Table exported in CSV had column order preserved.
I also have trouble exporting CSV data with 'latin-1' encoding, which I did not have before

Is this possible or I am dreaming and it never worked ? :/

@lilila lilila added the !deprecated-label:bug Deprecated label - Use #bug instead label Jul 1, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.59. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@lilila
Copy link
Author

lilila commented Aug 12, 2020

I come back on this issue, the problem is still not resolved with superset 37.
Here is an example :

The chart :

Screenshot 2020-08-12 at 15 46 45

and the CSV export :

Screenshot 2020-08-12 at 15 46 50

As you can see, the columns' order is modified and additionally the names of the columns were replaced by the variables :(

@michalgala
Copy link

I have the same issue, and it can be quite annoying for tables with many columns

@lilila
Copy link
Author

lilila commented Aug 18, 2020

I found out the problem (at least for the table export) comes from this line :
https://github.com/apache/incubator-superset/blob/ca9ca995109ee5251918b9df60980bffaf9b9a24/superset/viz.py#L325

The set function does not preserve the original order , I have seen this list(set( .... )) or set(gb) in many places in the viz.py file.
Is there any better way to preserve columns' order and make sure there is no duplicate?

@michalgala
Copy link

michalgala commented Aug 18, 2020

As a quick fix you could use:

sorted(list(gb + columns), key=list(gb + columns).index)
However, there might be some performance issues if you have many columns.

OR

list(dict.fromkeys(list(gb + columns)).keys())

@junlincc
Copy link
Member

Hi Lila, our team mentioned that you have been providing valuable product feedbacks and requests in the community. I would like to invite you to join Superset new designated user panels. I couldn't find you on Slack, would you mind sharing your email with me and I can share more info with you if you are interested. Thanks! @lilila

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
!deprecated-label:bug Deprecated label - Use #bug instead
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants