Skip to content

Commit

Permalink
fix(rust): floating point CSV parsing with escaping and whitespace (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
csko committed Feb 26, 2023
1 parent cc487a1 commit d49356b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion polars/polars-io/src/csv/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ where
return self.parse_bytes(
bytes,
ignore_errors,
needs_escaping,
false, // escaping was already done
_missing_is_null,
);
}
Expand Down
15 changes: 15 additions & 0 deletions polars/tests/it/io/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,3 +1078,18 @@ fn test_try_parse_dates_3380() -> PolarsResult<()> {
assert_eq!(df.column("validdate")?.null_count(), 0);
Ok(())
}

#[test]
fn test_leading_whitespace_with_quote() -> PolarsResult<()> {
let csv = r#"
"ABC","DEF",
"24.5"," 4.1"
"#;
let file = Cursor::new(csv);
let df = CsvReader::new(file).finish()?;
let col_1 = df.column("ABC").unwrap();
let col_2 = df.column("DEF").unwrap();
assert_eq!(col_1.get(0)?, AnyValue::Float64(24.5));
assert_eq!(col_2.get(0)?, AnyValue::Float64(4.1));
Ok(())
}

0 comments on commit d49356b

Please sign in to comment.