Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1077239]
[LanX]: I told you the story about the “new" currency trading system of Dresdner Bank
[LanX]: ?
[Corion]: No, or I don't remember the story ;)
LanX my favourite don't tell me the proof of concept is good enough for production anecdote
[ambrus]: ah, it's one of thos
[Eily]: what, there's a difference between proof of concept and production?
[LanX]: 20 years ago traders were complaining about the latency of the trading system...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2017-03-29 11:43 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (349 votes). Check out past polls.