Re: How to remove trailing commas and points from a CSV file ?



On Thu, Jun 26, 2008 at 1:14 PM, <perez.erasmo@xxxxxxxxx> wrote:
Hi dear Jeff:

Thank you very much for your help

Yiur script is working flawlessly

Just another question:

How could I re-write your script in order to treat the __DATA__
portion of your code as an external file ?

I happen to have the whole CSV file and I would not want to mix
directly with it, but to reference it from the perl code

How could I accomplish that ?

Should I substitue the <DATA> for the name of the CSV file in the perl code ?

Thank you very much for any help

Regards

Erasmo

Replace:
while(<DATA>) {
with
while( <> ) {
and then call the script like:
script.pl datafile
or replace it with
open( my $fileHandle, "< datafile" ) or die;
while( <$fileHandle> ) {
.



Relevant Pages

  • Re: How to remove trailing commas and points from a CSV file ?
    ... Thank you very much for you suggestion about the sustitution of the ... required to treat separately the CSV file (from the perl code). ... Yiur script is working flawlessly ...
    (perl.beginners)
  • Calculating Column Averages from a CSV File
    ... I am trying to calculate column averages (excluding 0's) for all the ... columns in a CSV file except the first column. ... perl code, perl is calculating the 2nd column's average 9 times rather ...
    (perl.beginners)
  • Updating table from external file?
    ... in field X of a table from an external file: ... Say you have a csv file with two items for each of ... Jonathan Grobe Books ... Prev by Date: ...
    (microsoft.public.access.gettingstarted)