Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Obtain CSV File from text

by Tux (Abbot)
on Mar 06, 2014 at 15:19 UTC ( #1077239=note: print w/replies, xml ) Need Help??


in reply to Obtain CSV Fiile from text

That line comes from a CSV producer. Is it possible to ask (them) to add a field that *only* has the source file?

  • What if the file name becomes a URI?
  • What if the file name will contain spaces?
  • What if the comment changes?
  • What if the file name will contain special characters like " or ,, that are totally valid in file names?
  • What if the file name is case(in)sensitive?
  • What if the path becomes relative or starts with a drive letter?

Assuming the line comes out the file named export.csv, you could try an overly safe approach like this:

$ cat export.csv 3,"2014-02-19 14:29:05","Extracted 1 Unfulfilled Reconciliation record +s into /opt/mysql/backup/recon/201312/input/UNFULFILLED_RECONCILIATIO +N_20130225.CSV","URECONCILIATION" $ perl -MText::CSV_XS=csv -wE'for(@{csv(in=>"export.csv")}){say for ma +p{s/.* into //i;$_}grep/\.csv/i=>@$_}' /opt/mysql/backup/recon/201312/input/UNFULFILLED_RECONCILIATION_201302 +25.CSV $

Requires Text::CSV_XS-1.04, but it is a one-liner now.


Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1077239]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2017-02-23 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (338 votes). Check out past polls.