[NTLUG:Discuss] scripting foo help
Stuart Johnston
saj at thecommune.net
Thu Jul 2 12:29:51 CDT 2009
Dan Wright - SPCA of Texas wrote:
>>> 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 :)
I think you mean fu? ;)
>
> but yes i would need to modify the file inplace so
> where would i put the -i
At the beginning is fine:
perl -i -n -a ...
More information about the Discuss
mailing list