Skip to content

Commit

Permalink
fix: fix csv reader (#95)
Browse files Browse the repository at this point in the history
- remove default preview chunksize because laputa is the one who decide for that
- return an iterator only if the type of the reader is not a dataframe
  • Loading branch information
Sanix-Darker authored Mar 2, 2022
1 parent b1ff48b commit 750748c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions peakina/readers/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

FilePathOrBuffer = Union[str, bytes, PathLike[str], PathLike[bytes]]

# The chunksize value for previews
PREVIEW_CHUNK_SIZE = 1024


@wraps(pd.read_csv)
def read_csv(
Expand All @@ -37,9 +34,9 @@ def read_csv(
# keep the first row 0 (as the header) and then skip everything else up to row `preview_offset`
skiprows=range(1, preview_offset + 1),
nrows=preview_nrows,
chunksize=PREVIEW_CHUNK_SIZE,
)
return next(chunks)
# to prevent for the chunksize not present in params
return next(chunks) if not isinstance(chunks, pd.DataFrame) else chunks

return pd.read_csv(
filepath_or_buffer,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "peakina"
version = "0.7.3"
version = "0.7.4"
description = "pandas readers on steroids (remote files, glob patterns, cache, etc.)"
authors = ["Toucan Toco <dev@toucantoco.com>"]
readme = "README.md"
Expand Down

0 comments on commit 750748c

Please sign in to comment.