fastexcel icon indicating copy to clipboard operation
fastexcel copied to clipboard

header_row does not work as expected if there are blank rows

Open noctuid opened this issue 10 months ago • 6 comments

If I put expect the header on e.g. row index 15, but there are blank rows (at least at the beginning of the sheet), I cannot do header_row=15. It looks like they are ignored, so I have to put in a lower index.

noctuid avatar Apr 17 '24 17:04 noctuid

Hello! can you please provide an excel sheet example?

PrettyWood avatar Apr 17 '24 17:04 PrettyWood

I will try to create a basic sheet to reproduce. It seems the issue is not actually with blank rows, but there is some other reason I am having to put in a much lower index than I expect.

noctuid avatar Apr 17 '24 18:04 noctuid

It looks like it does have to do with empty rows in some case.. not exactly clear to me, but it's very easy to reproduce with this file:

TestFastExcelRead.xlsx

I have the header row on row 8 (0-based; 9 in excel) but have to specify it as 6. You can also remove that "Note 1" cell to change things.

def test_row_issue():
    reader = read_excel("...TestFastExcelRead.xlsx")
    ws = reader.load_sheet("Sheet1", header_row=6)
    df = ws.to_pandas()

noctuid avatar Apr 17 '24 19:04 noctuid

I'll try to dig into it this weekend

PrettyWood avatar Apr 17 '24 22:04 PrettyWood

seem related to #209

lukapeschke avatar Apr 18 '24 15:04 lukapeschke

see https://github.com/ToucanToco/fastexcel/issues/209#issuecomment-2239211891

PrettyWood avatar Jul 19 '24 13:07 PrettyWood