I'm trying to parse a long CSV that has many components that are repeated, and I'm trying to collapse it down within particular fields
Headers are on the top line, and I'm trying to build a hash array based on the names found therein, so this is dynamic.
A B C D E F G (header line)
a b c d E'f g (resulting new line)
a b c D'e f g (resulting new line)
a b c d E'f g (deleted, with E' embedded within last recent new line)
a b c d E'f g (deleted, with E' embedded within last recent new line)
a b c D'e f g (resulting new line)
The input above would collapse from 6 lines to 4
The output changes based on the X' notation within the file, but a b c stays the same for the most part.
The output would be collapsed (where a b c will be the same, and when changes in D or E change, they are concatenated with prior lines with same A', B's, and C's)
The question is how I can dynamically build an array_name{A}{B}{C}{D}{E}{F}{G} based on header names, and then be able to modify anything in that hash array, given the number of fields could change from file to file, and I want to possibly modify an element (to concatenate) and toss out extra lines and leaving the minimal unique combinations of A B C
For example, these files would have the same fileserver name (A), Directory Path and file (B), Inheritance value (C), Permissions (D), username (E), etc. The username and permissions will change but the commercial software outputting this only knows to have 1 line per unique database record (each user has specific permissions on a file found on a fileserver, and I'm trying to collapse lines down as much so that everyone with the same permission level on a file are all seen on the same line)
I'm stumped on how to build a dynamic array with arbitrary depth and then be able to change items in that array of a table to reflect changes.
Am I over-thinking this by only seeing a hash array solution? It seems ideal. I just don't know how to build an array as mentioned above on the fly, and then access any component I need to concatenate on or compare with.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.