We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Could we have an example of how to implement a custom Proc for a hash_transformations say on this page: https://github.com/tilo/smarter_csv/wiki/Hash-Transformations
There is one on the header_transformations page but it doesn't seem to work the same way for hash_transformations
My guess didn't work:
filter_posts = Proc.new {|hash, args=nil| keys = (args.nil? || args.empty?) ? hash.keys : ( args.is_a?(Array) ? args : [ args ] ) # this is just taken from strip_spaces keys.each {|key| hash[key].strip! unless hash[key].nil? } hash } } options = { hash_transformations: [ filter_posts, :strip_spaces, :remove_blank_values ] } data = SmarterCSV.process('/tmp/test.csv', options) => [{"Category"=>"Red", "FirstName"=>"John", "Age"=>"35"}]
The text was updated successfully, but these errors were encountered:
In answer to my own question, here's an example for date formatting:
filter_posts = Proc.new {|hash| hash[:date] = Date.strptime(hash[:date], "%d/%m/%y") if hash[:date].is_a?(String) # Need to return the hash hash } options = { hash_transformations: [ filter_posts ] } data = SmarterCSV.process('/tmp/test.csv', options)
Sorry, something went wrong.
Ear-marked for v2.0
No branches or pull requests
Could we have an example of how to implement a custom Proc for a hash_transformations say on this page: https://github.com/tilo/smarter_csv/wiki/Hash-Transformations
There is one on the header_transformations page but it doesn't seem to work the same way for hash_transformations
My guess didn't work:
The text was updated successfully, but these errors were encountered: