Skip to content

Commit 3ea1899

Browse files
committed
Filter out empty lines parsed as null rows
Newer polars versions parse empty/blank lines in GTF files as rows with all-null values. Filter these out early by dropping rows where seqname is null.
1 parent ac0be8c commit 3ea1899

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

gtfparse/read_gtf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def parse_with_polars_lazy(
110110
except polars.exceptions.ShapeError:
111111
raise ParsingError("Wrong number of columns")
112112

113+
# Drop empty lines that may appear as all-null rows
114+
df = df.filter(polars.col("seqname").is_not_null())
115+
113116
df = df.with_columns([
114117
polars.col("frame").fill_null(0),
115118
polars.col("attribute").str.replace_all('"', "'")

0 commit comments

Comments
 (0)