diff --git a/crates/polars-io/src/csv/read/utils.rs b/crates/polars-io/src/csv/read/utils.rs index 651ecc8328ec..61a14399237a 100644 --- a/crates/polars-io/src/csv/read/utils.rs +++ b/crates/polars-io/src/csv/read/utils.rs @@ -129,6 +129,9 @@ fn decompress_impl( }, }; } + if line_count == n_rows { + out.truncate(buf_pos); // retain only first n_rows in out + } out }, }) diff --git a/crates/polars/Cargo.toml b/crates/polars/Cargo.toml index 54a47ad4546c..49204000d01d 100644 --- a/crates/polars/Cargo.toml +++ b/crates/polars/Cargo.toml @@ -213,7 +213,13 @@ string_pad = ["polars-lazy?/string_pad", "polars-ops/string_pad"] string_reverse = ["polars-lazy?/string_reverse", "polars-ops/string_reverse"] string_to_integer = ["polars-lazy?/string_to_integer", "polars-ops/string_to_integer"] take_opt_iter = ["polars-core/take_opt_iter"] -timezones = ["polars-core/timezones", "polars-lazy?/timezones", "polars-io/timezones", "polars-sql?/timezones"] +timezones = [ + "polars-core/timezones", + "polars-lazy?/timezones", + "polars-io/timezones", + "polars-ops/timezones", + "polars-sql?/timezones", +] to_dummies = ["polars-ops/to_dummies"] top_k = ["polars-lazy?/top_k"] trigonometry = ["polars-lazy?/trigonometry"] diff --git a/crates/polars/tests/it/io/csv.rs b/crates/polars/tests/it/io/csv.rs index 22d6d644a6fc..1b78969093e2 100644 --- a/crates/polars/tests/it/io/csv.rs +++ b/crates/polars/tests/it/io/csv.rs @@ -2,7 +2,6 @@ use std::io::Cursor; use std::num::NonZeroUsize; use polars::io::RowIndex; -use polars_core::export::chrono; use polars_core::utils::concat_df; use super::*; @@ -41,7 +40,10 @@ fn write_csv() { } #[test] +#[cfg(feature = "timezones")] fn write_dates() { + use polars_core::export::chrono; + let s0 = Series::new("date", [chrono::NaiveDate::from_yo_opt(2024, 33), None]); let s1 = Series::new("time", [None, chrono::NaiveTime::from_hms_opt(19, 50, 0)]); let s2 = Series::new(