Conal has asked for the wisdom of the Perl Monks concerning the following question:
i have files that contain data like this below
I want to disregard any whitespace and any extraneous characters that show up after the time in column 2. I also want to disregard the last character after the decimal place no rounding) in the first column ... so if i were to write the above file back .. it would look like this ..1.4567 ,11:00:00 1.4571 ,11:00:01 , 1.4567 ,11:58:00rftft 1.4566 , 1.5555 ,11:43:00
a snippet of my readfile code looks like this at the minute1.456,11:00:00 1.457,11:00:01 1.456,11:58:00 1.555,11:43:00
can anyone pls help me clean up my code, to catch these anomalies in my input file? i need to run calculations of the final datawhile (<DATAFILE>) { chomp $_; ($quote,$time) = split(",", $_); chop($quote);chop($quote); ($hour,$minute,$second) = split(":",$time); }
thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dealing with whitespace and using chop when reading delimited files
by FunkyMonk (Bishop) on Mar 12, 2008 at 20:02 UTC | |
|
Re: dealing with whitespace and using chop when reading delimited files
by pc88mxer (Vicar) on Mar 12, 2008 at 20:04 UTC | |
|
Re: dealing with whitespace and using chop when reading delimited files
by runrig (Abbot) on Mar 12, 2008 at 20:05 UTC | |
|
Re: dealing with whitespace and using chop when reading delimited files
by kyle (Abbot) on Mar 12, 2008 at 20:11 UTC | |
|
Re: dealing with whitespace and using chop when reading delimited files
by Tux (Canon) on Mar 13, 2008 at 13:15 UTC |