in reply to Re^3: Converting File Delimiters
in thread Converting File Delimiters

Ok, I figured out that the script is failing on the first row that contains the double-quotes around the field with the comma contained within the field.

See rows two and three in the data below. This is a very small sample, actual file has more columns and 25000 rows .

988A5521, 98_1V_HB, Hel Product Pool (Pds Dd), false, store, false 988A5707, 98_1V_HB, "Chinook, IPT ME Support", false, store, false 988A5708, 98_1V_HB, "Chinook, ME Factory Supt", false, store, false 988A5761, 98_1V_HB, Tandem Rotor Configuration, false, store, false

In my case it stops on row 68, which is row 2 in the above sample. Would like it to look like sample below

988A5521|98_1V_HB|Hel Product Pool (Pds Dd)|false| store|false 988A5707|98_1V_HB|Chinook, IPT ME Support|false|store|false 988A5708|98_1V_HB|Chinook, ME Factory Supt|false|store|false 988A5761|98_1V_HB|Tandem Rotor Configuration|false|store|false

Any Ideas why it would die on the row with the double-quotes? Thanks, Mike

Replies are listed 'Best First'.
Re^5: Converting File Delimiters
by BrowserUk (Patriarch) on Aug 14, 2012 at 02:43 UTC

    This works:

    C:\test>perl -ple"$_ = join '|', m[(\s*\x22[^\x22]+\x22\s*|[^,]+)]g" 988A5521, 98_1V_HB, Hel Product Pool (Pds Dd), false, store, false 988A5521| 98_1V_HB| Hel Product Pool (Pds Dd)| false| store| false 988A5707, 98_1V_HB, "Chinook, IPT ME Support", false, store, false 988A5707| 98_1V_HB| "Chinook, IPT ME Support"| false| store| false 988A5708, 98_1V_HB, "Chinook, ME Factory Supt", false, store, false 988A5708| 98_1V_HB| "Chinook, ME Factory Supt"| false| store| false 988A5761, 98_1V_HB, Tandem Rotor Configuration, false, store, false 988A5761| 98_1V_HB| Tandem Rotor Configuration| false| store| false ^Z

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      Thanks! This worked great! Thanks Again, Mike