Feature proposal: Map column names when exporting CSV
Opened this issue · 3 comments
DanielHeath commented
I'm seeing an issue where column names are:
A) converted to lowercase (they are uppercase in the SQL)
B) cannot be remapped in ruby code (without hacking around in the enumerator).
Would a PR to add the map: {}
syntax to CSV exports be mergeable?
diogob commented
Sorry, I don't follow you.
Could you paste a snippet of the desired code that you would like to use?
DanielHeath commented
Lets say you have CSV imports and exports, and want round-tripping to work.
You export with:
Foo.select('bar as Baz').copy_to_string
then import with:
Foo.copy_from filename, :map => {'Baz' => 'bar'}
However, the CSV from copy_to_string
has a header row of baz
, not Baz
.
diogob commented
I see your point. It makes sense to have symetrical APIs on exports and imports.