On Mon, Mar 19, 2001 at 07:59:33PM -0700, Warren Pollans wrote:
> Ron Savage wrote:
>
> I was able to get the script to work by explicitly adding a record
> separator ('^M' in vi) at the end of each line - didn't have to define
> the column names. I got here by creating a table and seeing what was in
> it. I had a large tab-delimited file (from star-office spreadsheet)
> which for which Stacy's script produced the same no-output result -
> adding '^M' to the end of each line fixed that problem.
>
> Stacy, it may be that explicitly defining '\n' as your EOL char is what
> fixed your problem.
DBD::CSV can read files with different record separators (and different
column separators also). The csv_eol attribute of the database handle
($dbh) contains the characters that separate each record from the next
one. csv_eol defaults to "\015\012" (aka "\r\n") which is the msdos
style line separator. For unix style eol, use "\012".
# this should do the trick:
$dbh->{csv_eol} = "\012";
# csv_eol can also be specified as part of the dsn:
$csv_dsn = "dbi:CSV:f_dir=/path/to/csvfiles;csv_eol=\012";
$dbh = DBI->connect($dsn) or die $DBI::errstr;
For more details, see the DBD::CSV manpage.
-C.