Closed phochste closed 9 years ago
The corresponding option in Catmandu::Exporter::CSV and Catmandu::Exporter::XLS is header
, in Catmandu::Exporter::Table it is named columns
. We should stick to one common name for tabular-data importers and exporters.
In the synopsis of Catmandu::Exporter::Table you use header
catmandu convert CSV to Table --fields id,name --header ID,Name < sample.csv
in the configuration section columns
Table output can be controlled with the options fields, columns, widths, and condense
Which one should we use? I would use header
"Header" has also another meaning in Catmandu::Exporter::XLS(X): it is a boolean there to switch on/off headers. Same is true in Catmandu::Exporter::CSV. I don't know if this double meaning is valid in Catmandu::Exporter::Table
With the header
option of Catmandu::Importer::CSV you could do something like this:
$ printf "a,b,c\n1,2,3" | catmandu convert CSV --header 1 --fields x,y,z to YAML
---
x: '1'
y: '2'
z: '3'
...
Would that be a solution for the XLS(X) importer?
In fact Catmandu::Exporter::Table uses columns
but the documentation says header
. fields
is used to specify field names and columns
/header
/as_header
to specify the column names. How about:
header
: toggle column names on/offcolumns
: column names in the header. Set to field names by default. Used as new field names for importersfields
: field namesSo for Catmandu::Importer::XLS the option should be named columns
instead of as_columns
. And Catmandu::Exporter::XLS should also get a columns
option.
See pr #3. I will also work on the exporter modules.
And Catmandu::Exporter::XLS should also get a columns option.
Do we really need this option for the XLS(X) exporters, as software like Excel, Calc, ... already provides column coordinates by default?
Option columns
is meant to controll column names in the header, for instance "Herausgeber" for field "publisher". This is useful for all tabular exporters.
I need to process XLS files that have such bad header names (containing new lines, slashes, spaces, parentheses, etc) that it is impossible to manipulate with Catmandu fixes. The as_columns option translates all the column names into coordinates: A,B,C,D, etc.