ToucanToco / fastexcel

A Python wrapper around calamine
http://fastexcel.toucantoco.dev/
MIT License
82 stars 4 forks source link

header_row does not work as expected if there are blank rows #233

Open noctuid opened 2 months ago

noctuid commented 2 months ago

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.

PrettyWood commented 2 months ago

Hello! can you please provide an excel sheet example?

noctuid commented 2 months ago

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 commented 2 months ago

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()
PrettyWood commented 2 months ago

I'll try to dig into it this weekend

lukapeschke commented 2 months ago

seem related to #209