-
-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:convert_values_to_numeric_unless_leading_zeros drops leading zeros #151
Comments
Which version of the library are you using? I'm using version 1.2. |
As a workaround I can unset #!/usr/bin/env ruby
require 'smarter_csv'
path = File.expand_path('data.csv', __dir__)
data = SmarterCSV.process(
path,
{
col_sep: "\t",
convert_values_to_numeric: { except: [:start, :end] },
hash_transformations: [:remove_blank_values ]
}
)
data.each do |row|
i, s, e = row[:id], row[:start], row[:end]
puts "id: #{i} (#{i.class})\tstart: #{s} (#{s.class})\tend: #{e} (#{e.class})"
end
# => prints:
id: 40456 (Integer) start: 0900 (String) end: 2100 (String)
id: 40881 (Integer) start: 0900 (String) end: 0200 (String)
id: 74581 (Integer) start: 0900 (String) end: 1645 (String)
id: 98359 (Integer) start: 0900 (String) end: 1800 (String)
id: 141635 (Integer) start: 0900 (String) end: 1645 (String)
id: 178431 (Integer) start: 0800 (String) end: 0200 (String)
id: 220975 (Integer) start: 1300 (String) end: 1700 (String)
id: 266212 (Integer) start: 0900 (String) end: 1800 (String)
id: 276688 (Integer) start: 0900 (String) end: 2200 (String)
id: 288836 (Integer) start: 0900 (String) end: 1700 (String) Which arguably is better semantics. But isn't this what |
I had the same issue. I don't think this is fixed. The work around did work tho. |
the solution for 1.x is the way to go: This is ear-marked for 2.0 |
how do we do this in 2.0? i dont want any conversions at all, i just want all strings |
e.g.
|
@fuzzygroup it is now documented here: https://github.com/tilo/smarter_csv/blob/main/docs/data_transformations.md#convert-values-to-numeric |
Steps to reproduce:
Given a file called
data.csv
with the following:Run the following script:
Expected
Actual
The text was updated successfully, but these errors were encountered: