Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/formats/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,21 @@ fn csv_field_to_string(value: &Value) -> String {
Value::Null => String::new(),
Value::Bool(b) => b.to_string(),
Value::Int(i) => i.to_string(),
Value::Float(f) => f.to_string(),
Value::Float(f) => {
let s = f.to_string();
// Ensure float representation always contains a decimal point
// so that CSV type inference re-parses it as Float, not Int.
if s.contains('.')
|| s.contains('e')
|| s.contains('E')
|| s.contains("inf")
|| s.contains("NaN")
{
s
} else {
format!("{s}.0")
}
}
Value::String(s) => s.clone(),
Value::Bytes(b) => format!("{b:?}"),
Value::Array(_) | Value::Map(_) => {
Expand Down
Loading