Catmandu::Importer::CSV(3pm) | User Contributed Perl Documentation | Catmandu::Importer::CSV(3pm) |
Catmandu::Importer::CSV - Package that imports CSV data
# From the command line # convert a CSV file to JSON catmandu convert CSV to JSON < journals.csv # set column names if CSV file has no header line echo '12157,"The Journal of Headache and Pain",2193-1801' | \ catmandu convert CSV --header 0 --fields 'id,title,issn' to YAML # set field separator and quote character echo '12157;$The Journal of Headache and Pain$;2193-1801' | \ catmandu convert CSV --header 0 --fields 'id,title,issn' --sep_char ';' --quote_char '$' to XLSX --file journal.xlsx # In a Perl script use Catmandu; my $importer = Catmandu->importer('CSV', file => "/foo/bar.csv"); my $n = $importer->each(sub { my $hashref = $_[0]; # ... });
The package imports comma-separated values (CSV). The object fields are read from the CSV header line or given via the "fields" parameter. Strings in CSV are quoted by "quote_char" and fields are separated by "sep_char".
Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The methods are not idempotent: CSV streams can only be read once.
Catmandu::Exporter::CSV, Catmandu::Importer::XLS
2023-03-03 | perl v5.36.0 |