Skip to content

Step "Excel File Output" | option: Row index #229

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

Closed
bernabeudario opened this issue Feb 2, 2025 · 3 comments
Closed

Step "Excel File Output" | option: Row index #229

bernabeudario opened this issue Feb 2, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@bernabeudario
Copy link
Contributor

bernabeudario commented Feb 2, 2025

Hi,

When adding the Step “Excel File Output” the option “Row index” is shown as disabled or “False” (indicating that indexes will not be shown).

The code it generates is something like:
sqlQuery2.to_excel(“output/summary.xls”, engine='xlsxwriter', header=True)

By default “.to_excel” has the value “index=True” (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html) so in the resulting Excel you will see the indexes.

In order not to see the indexes you have to activate the “Row index” option and then deactivate it again. The code looks like this:
sqlQuery2.to_excel(“output/summary.xls”, engine='xlsxwriter', header=True, index=False).

The “index=False” option should be included by default in the original code.

Greetings

@tgourdel
Copy link
Contributor

tgourdel commented Feb 5, 2025

Hi @bernabeudario, that was decided by design because most of the time you don't want the index to be added as a column automatically when creating a CSV or excel file. Now, I think we should have the option to control that though, but I would probably keep it as False by default. Does it make sense?

@tgourdel tgourdel added the enhancement New feature or request label Feb 5, 2025
@bernabeudario
Copy link
Contributor Author

Hi @tgourdel

I agree with you that it should be “False” by default. The issue is that currently, since it is not indicated in the code, it defaults to “True” (https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html).
By default Amphi generates this code:
sqlQuery2.to_excel(“output/summary.xls”, engine='xlsxwriter', header=True).

If you notice “index” is not included. So Pandas will use the value “True”.

Because of that, to not show the indexes Amphi should indicate “index:False” by default:
sqlQuery2.to_excel(“output/summary.xls”, engine='xlsxwriter', header=True, index=False).

Regards

tgourdel added a commit that referenced this issue Mar 31, 2025
@tgourdel
Copy link
Contributor

Fixed in 0.8.26! Thanks @bernabeudario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants