How can I skip first several lines of the Excel sheet?

前端 未结 2 1341
别那么骄傲
别那么骄傲 2020-12-20 07:59

Using openpyxl I tried to read from the fifth line for some files. The files\' first four lines are the header. Then the main content has a different format fro

相关标签:
2条回答
  • 2020-12-20 08:14

    You can skip the first N rows by passing the optional min_row argument. Note that this uses a 1-base index, so min_row=2 starts on the second row and min_row=5 skips the first four rows. You would be using something like this:

    for index, row in enumerate(ws.iter_rows(min_row=5)):

    Full iter_rows documentation.

    0 讨论(0)
  • 2020-12-20 08:30

    You can pass a range into ws.iter_rows('A4:Z256') but you're probably better off using ws.get_squared_range(1, 5,)

    0 讨论(0)
提交回复
热议问题