(self)
| 468 | assert table.column_names == names |
| 469 | |
| 470 | def test_header_skip_rows(self): |
| 471 | rows = b"ab,cd\nef,gh\nij,kl\nmn,op\n" |
| 472 | |
| 473 | opts = ReadOptions() |
| 474 | opts.skip_rows = 1 |
| 475 | table = self.read_bytes(rows, read_options=opts) |
| 476 | self.check_names(table, ["ef", "gh"]) |
| 477 | assert table.to_pydict() == { |
| 478 | "ef": ["ij", "mn"], |
| 479 | "gh": ["kl", "op"], |
| 480 | } |
| 481 | |
| 482 | opts.skip_rows = 3 |
| 483 | table = self.read_bytes(rows, read_options=opts) |
| 484 | self.check_names(table, ["mn", "op"]) |
| 485 | assert table.to_pydict() == { |
| 486 | "mn": [], |
| 487 | "op": [], |
| 488 | } |
| 489 | |
| 490 | opts.skip_rows = 4 |
| 491 | with pytest.raises(pa.ArrowInvalid): |
| 492 | # Not enough rows |
| 493 | table = self.read_bytes(rows, read_options=opts) |
| 494 | |
| 495 | # Can skip rows with a different number of columns |
| 496 | rows = b"abcd\n,,,,,\nij,kl\nmn,op\n" |
| 497 | opts.skip_rows = 2 |
| 498 | table = self.read_bytes(rows, read_options=opts) |
| 499 | self.check_names(table, ["ij", "kl"]) |
| 500 | assert table.to_pydict() == { |
| 501 | "ij": ["mn"], |
| 502 | "kl": ["op"], |
| 503 | } |
| 504 | |
| 505 | # Can skip all rows exactly when columns are given |
| 506 | opts.skip_rows = 4 |
| 507 | opts.column_names = ['ij', 'kl'] |
| 508 | table = self.read_bytes(rows, read_options=opts) |
| 509 | self.check_names(table, ["ij", "kl"]) |
| 510 | assert table.to_pydict() == { |
| 511 | "ij": [], |
| 512 | "kl": [], |
| 513 | } |
| 514 | |
| 515 | def test_skip_rows_after_names(self): |
| 516 | rows = b"ab,cd\nef,gh\nij,kl\nmn,op\n" |
no test coverage detected