Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a large, sorted, CSV file arranged along these lines:
Desk,Left-Drawer,Paperclips Desk,Left-Drawer,Pens Desk,Right-Drawer,Ruler Filing-Cabinet,Top-Drawer,Files
To make it more human-readable, I would like to pretty-print it so that column entries are omitted if they duplicate the one above. The desired output would be something like this:
Desk | Left-Drawer | Paperclips | | Pens | Right-Drawer | Ruler Filing-Cabinet | Top-Drawer | Files
One way of doing this would be to build the table line-by-line, testing if $column_one_value == $last_column_one_value and blanking it if necessary. However, as the number of columns increases, this becomes increasingly ugly.
I was therefore wondering if there were any modules which would help? I’ve been looking through Text::ASCIITable, Text::Table and the like and several of the List ones, but without success. Does anyone know of a nicer way of doing this than looping through and testing for previous values?
Many thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pretty-Print Table (Omitting Duplicates)
by Corion (Patriarch) on Apr 24, 2011 at 09:40 UTC | |
by Anonymous Monk on Apr 24, 2011 at 09:56 UTC | |
|
Re: Pretty-Print Table (Omitting Duplicates)
by chrestomanci (Priest) on Apr 24, 2011 at 20:23 UTC |