Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Ability to specify header values and ignore headers in the csv file #27
Thanks for the CSV library!
In order to use the Map parsed from each row with Ecto, I need to define the headers as atoms that exactly match my model:
When I do this, the first line of the file that contains the headers is picked up as a row of values, which I don't want.
Is there a way to skip that first row the way
Would having two different attributes work better? Maybe
(My workaround is to define a function that matches on one of the things I know will be in the Map for that first unwanted record, and ignore it:
Interesting usecase, thanks for raising this!
I think in this case the solution could be done outside the
File.stream!("/Users/wsmoak/Downloads/transactions.csv") |> Stream.drop(1) |> CSV.decode(headers: [:date, :description, :original_description, :amount, :transaction_type, :category, :account_name, :labels, :notes])
The library does not filter or skip rows in any case -
Hope this works for you, feel free to reopen if you have more questions / this is turning into a bug!