Scripting Question

Patton Echols p.echols at comcast.net
Sat Feb 14 03:49:08 UTC 2009


On 02/13/2009 06:44 PM, Lucio M Nicolosi wrote:
> Patton Echols wrote:
>   
>> I have a fairly massive flat file, comma delimited, that I want to 
>> extract info from.  Specifically, I want to extract the first and last 
>> name and email addresses for those who have them to a new file with just 
>> that info. (The windows database program that this comes from simply 
>> will not do it)  I can grep the file for the @ symbol to at least 
>> exclude the lines without an email address (or the @ symbol in the notes 
>> field)  But if I can figure this out, I can also adapt what I learn for 
>> the next time.  Can anyone point me in the right direction for my "light 
>> reading?"
>>
>> By the way, I used 'head' to get the first line, with the field names.  
>> This is the first of about 2300 records, the reason not to do it by hand.
>>
>> patton at laptop:~$ head -1 contacts.txt
>> "Business Title","First Name","Middle Name","Last Name","","Business 
>> Company Name","","Business Title","Business Street 1","Business Street 
>> 2","Business Street 3","Business City","Business State","Business 
>> Zip","Business Country","Home Street 1","Home Street 2","Home Street 
>> 3","Home City","Home State","Home Zip","Home Country","Other Street 
>> 1","Other Street 2","Other Street 3","Other City","Other State","Other 
>> Zip","Other Country","Assistant Phone","Business Fax Number","Business 
>> Phone","Business 2 Phone","","Car Phone","","Home Fax Number","Home 
>> Phone","Home 2 Phone","ISDN Phone","Mobile Phone","Other Fax 
>> Number","Other Phone","Pager 
>> Phone","","","","","","","","","","","","","Business Email","","Home 
>> Email","","Other 
>> Email","","","","","","","","","","","","Notes","","","","","","","","","","","","","","Business 
>> Web Page"
>>
>>
>>   
>>     
> Sure it's not an elegant solution, but couldn't you just import the 
> comma delimited data to a worksheet and edit it? OpenOffice or Symphony 
> would do it.
>
> L.
>
>   
I could, but I end up having to do something like this periodically.  I 
hoped to learn a quicker way to approach it.  Since I am on a deadline 
this  time around, I may grep the file as I said, then use a OO-calc  to 
delete the columns I don't want. 





More information about the ubuntu-users mailing list