The_DJ, thank you for this. I've learned a lot by slowly poring through this to learn how this worked, and realized that by making unique keys of SEVERAL fields together, that simplifies things greatly!
I've run into a problem that I'm not sure how to solve.
The entire file gets slurped in within a single line, but I discovered on my full data set that someone actually created filenames with commas in it, causing it to not output correctly.
Reading through the Text::CSV documentation (which apparently uses CSV_XS), I find something about a quote_char, but it defaults to a quote anyway.
Adding the reference to it specifically
my $aoa = csv( in => $filename, quote_char => "\"" );
Also proves ineffective, or rather no change. (I think that's the default anyway.)
The input data shows it as a quoted field, but I'm not sure what I'm doing wrong.
Input data looks like this:
10.15.106.71,"/ifs/PH01/PH01SUB/ENTNASIS02/PH02/SMB/Share/Share6/Emplo
+yee-Share/Contracts/Privacy and Disclosure/Disclosure Unit/Active Con
+tracts/County/Sample County/E00526, E00595 Sample County DA/2017-202
+0 M4385566/Emails & Correspondence/Welcome Letter.doc",FMRWX,Creator
+Owner,\ifs\PH01\PH01SUB\ENTNASIS02\PH02\SMB\Share\Share6\Employee-Sha
+re\Contracts,This folder only,Abstract\Creator Owner,"US PII (1/1),Do
+cument Passwords - 2.0 (1/1),US Social Security Number (1/1),GLBA (Gr
+amm-Leach Bliley Act) (1/1)","Credentials (1),Financial (1),PII (2)",
+4
After focusing a bit on the 1st part of the data (before the magic field), I noticed the quoted commas issue was there in all other lines containing more than one sensitive data type the entire time. (after the magic field)
So, somehow I need to figure out how to slurp in (as one field) anything with quotes and having commas within, but still comma separated.
Am I missing something too obvious in the docs?
Text::CSV#quote_char
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.