good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: problem with splitting file on whitespace: how to circumvent inconsistent formatting through fileby shadowsong (Pilgrim) |
on Jul 05, 2016 at 09:54 UTC ( [id://1167220]=note: print w/replies, xml ) | Need Help?? |
Hi angela2 I can see that you've already had some great responses - some more easily understood than others; so for posterity here are a couple of one-liners similar to what BrowserUk suggested here Re: problem with splitting file on whitespace: how to circumvent inconsistent formatting through file that also take into account tab delimited columns and numbers with decimal points. one-liner to print all columnsperl -F"\s*(?=[^\d,\.])" -wanle "print qq[@F]" badfile.txtone-liner to print column 1perl -F"\s*(?=[^\d,\.])" -wanle "print $F[0]" badfile.txt...use $F[n-1] to access column n, e.g. print $F[1] will print the value for column 2. quick explanation of command-line flags
Best Wishes,
In Section
Seekers of Perl Wisdom
|
|