Charles Farinella writes:
> I'm trying to import thousands of dated records from a comma delimited
> file into a MySQL table.
...
>       2:  Write some kind of script to rearrange the date format in my
>           .csv file.

Just a suggestion in addition to the good sed solutions already
offered:

Check out Perl's CSV module.  If your CSV's are non-trivial, this
might be more to your liking:

$ cat /tmp/csv
a,b,"c, d, e",f,g
"one,two","three,four",five,six,"look, an embedded double-quote """
$ perl -MText::CSV -e '
    my $csv = Text::CSV->new;
    while (<>) {
      if ($csv->parse($_)) {
        my @fields = $csv->fields;
        # swap elements 0 and 3
        ($fields[0], $fields[3]) = ($fields[3], $fields[0]);
        print join(",", @fields), "\n";
    }
  }
  ' /tmp/csv
f,b,c, d, e,a,g
six,three,four,five,one,two,look, an embedded double-quote "
$

Hope this helps,

--kevin
-- 
Kevin D. Clark          |                           |  Will hack Perl for
[EMAIL PROTECTED] | kdcNOSPAM@.alumni.unh.edu | fine food, good beer, 
Cabletron Systems, Inc. | PGP Key Available         |      or fun.
Durham, N.H. (USA)      |                           |


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to