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

Option to not drop rows containing only missing data #219

Closed
rben01 opened this issue Dec 6, 2022 · 1 comment · Fixed by #220
Closed

Option to not drop rows containing only missing data #219

rben01 opened this issue Dec 6, 2022 · 1 comment · Fixed by #220

Comments

@rben01
Copy link
Contributor

rben01 commented Dec 6, 2022

When reading an excel sheet into a dataframe, it can be handy to keep a record of the corresponding row numbers in the original sheet so that you know the origin of each row in your own Julia DataFrame. I would like to use something like this:

df = DataFrame(XLSX.gettable(xl_file[tab_name], xl_args...; xl_kwargs...))
rownum_offset = get(xl_kwargs, :first_row, 1)
df[!, :row_num] .= (1:nrow(df)) .+ rownum_offset

However, because XLSX always drops all non-missing rows, the rows in the DataFrame do not necessarily originate from consecutive rows in the excel sheet, and so this numbering scheme doesn't work.

Ideally XLSX.jl would provide an option to keep all-missing rows so that I could assign row number and then drop those rows myself.

@rben01
Copy link
Contributor Author

rben01 commented Dec 6, 2022

After a quick glance at the source code I think this would require add a keyword argument drop_empty_rows::Bool to eachtablerow (and all functions that eventually call it) and then changing if !isempty(r) to if !(isempty(r) && drop_empty_rows).

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

Successfully merging a pull request may close this issue.

1 participant