temporal has asked for the wisdom of the Perl Monks concerning the following question:
Sometimes I want to find the longest string under a particular column within a rather large, unsorted CSV file (several GB).
This can be useful to know for specifying sane database column size restrictions, etc. I've also found myself doing variations on this theme - wanting to do a quick and dirty comparison or operation based on an attribute of a particular column or columns in a delimited file.
Typically I'll do something like this:
perl -F, -lane 'print $t = length $F[0] <= $t ? next LINE : length $F[0]' file.csvJust wondering if anyone has a cleaner one-liner to accomplish this. There's got to be a sexier way. Or maybe just a more efficient way. Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Delimited File Analysis One-Liner?
by BrowserUk (Patriarch) on May 01, 2012 at 20:51 UTC | |
by temporal (Pilgrim) on May 01, 2012 at 21:17 UTC | |
by BrowserUk (Patriarch) on May 01, 2012 at 21:30 UTC | |
by temporal (Pilgrim) on May 02, 2012 at 15:21 UTC | |
by BrowserUk (Patriarch) on May 02, 2012 at 16:19 UTC | |
by temporal (Pilgrim) on May 02, 2012 at 19:13 UTC | |
|
Re: Delimited File Analysis One-Liner?
by Anonymous Monk on May 01, 2012 at 20:33 UTC | |
by Anonymous Monk on May 02, 2012 at 08:40 UTC |