mlong has asked for the wisdom of the Perl Monks concerning the following question:
I'm not sure how many monks use perl on Win32, but I am
trying to convert data from an Access database to
something that can be used by MySQL on a Linux machine.
The problem I have is that I can't export the data
directly to a CSV because there are carriage returns,
and or line feeds in the data in one of the columns. So I
am using perl to read the data into memory from the
Access database (ODBC) and strip out all of the
offending characters that break the CSV output. Then I
plan to update that column in each record with the
changed data. I am, however, having a terrible time
getting it to work. I'm not sure if it's my perl code or
some other problem.
Here is what I am doing:
while( my @row = $sth->fetchrow_array() ) { my $descriz = $row[1]; # IDTitolo my $title_id = $row[0]; # Descriz $descriz =~ s/\^M//g; $descriz =~ s/\n//g; $descriz =~ s/^\s+//g; $descriz =~ s/\s+$//g; print $descriz, "\n"; # $dbh->do( "UPDATE Titoli SET Descriz = '$descriz' WHERE IDTitolo += '$title_id'" ); }
For some reason the information on the first line of the
data from the Descriz field gets completely truncated.
Here is what a sample record (the Descriz column) looks like.
RATED R In yet another bid to shed her girl-next-door image, Sandra
Bullock tackles a difficult role in this riveting
psychological thriller directed by Barbet Schroeder
(Single White Female), and under his guidance...<truncated
for brevity>.
Notice specifically the line breaks. This is what seems
to be giving me trouble. But, like I said, after I've
run it through my substitutions, The first line "RATED
R" is gone completely.
Any help would be appreciated.
Thanks.
-Matt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl with MS Access Weirdness
by Jenda (Abbot) on Jan 28, 2003 at 00:26 UTC | |
by Cabrion (Friar) on Jan 28, 2003 at 02:07 UTC | |
by Jenda (Abbot) on Jan 28, 2003 at 12:59 UTC | |
|
Re: Perl with MS Access Weirdness
by Mr. Muskrat (Canon) on Jan 27, 2003 at 23:13 UTC | |
by mlong (Sexton) on Jan 27, 2003 at 23:38 UTC | |
|
Re: Perl with MS Access Weirdness
by fokat (Deacon) on Jan 28, 2003 at 05:25 UTC | |
by Cody Pendant (Prior) on Jan 28, 2003 at 05:41 UTC | |
|
Re: Perl with MS Access Weirdness
by Cody Pendant (Prior) on Jan 28, 2003 at 03:29 UTC | |
by mlong (Sexton) on Jan 28, 2003 at 04:31 UTC |