[NTLUG:Discuss] scripting foo help

Dan Wright - SPCA of Texas dwright at spca.org
Thu Jul 2 11:42:05 CDT 2009


 


> > I have a CSV file that needs " added to the ID fields like bellow, 
> > right now there missing the " ( ex: 1263831 instead of:  
> "1263831" and 
> > ID instead of: "ID"  )
> >  
> 
> Here is a Perl solution.  It will read from data.csv and 
> print the result to stdout.  You can add '-i' if you want it 
> to modify the file inplace.
> 
> perl -n -a -F"," -e '$F[0]=qq{"$F[0]"};print join(q{,}, @F);' data.csv
> 
> If you have any newlines within your data fields, this will break. 
> You'd need a full csv parser to handle that.

your foo is strong :) 

but yes i would need to modify the file inplace so
where would i put the -i 

thanks for your help.

Dan



More information about the Discuss mailing list