Skip to content

Instantly share code, notes, and snippets.

@andrefs
Created November 18, 2013 18:32
Show Gist options
  • Save andrefs/7532873 to your computer and use it in GitHub Desktop.
Save andrefs/7532873 to your computer and use it in GitHub Desktop.
Normalize CSV (read & write)
#!/usr/bin/env perl
use strict; use warnings;
use Data::Dump qw/dump/;
use feature qw/say/;
use Text::CSV::Auto;
use Text::CSV::Auto::ExportTo::CSV;
my $in = shift or die "Usage: $0 input.csv";
my $auto = Text::CSV::Auto->new($in);
my $exporter = Text::CSV::Auto::ExportTo::CSV->new(
auto => $auto,
file => "$in.fixed",
csv_options => {
quote_char => '"',
always_quote => 1,
sep_char => ',',
},
);
$exporter->export();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment