[wplug] Scripting - Text file manipulation help - probably perl

Mike Griffin mike at nbi.edu
Tue Mar 20 09:53:46 EST 2007


To understand better, you want to replace the tab characters with new lines,
correct?

perl -pi -e 's/[\t]/\n/g' filename  (note* it's sed, not perl.)

Do you also want to add the tags to the end of each newly created line as
shown in your example?


-Mike
 

-----Original Message-----
From: wplug-bounces+mike=nbi.edu at wplug.org
[mailto:wplug-bounces+mike=nbi.edu at wplug.org] On Behalf Of Gentgeen
Sent: Tuesday, March 20, 2007 10:11 AM
To: WPLUG
Subject: [wplug] Scripting - Text file manipulation help - probably perl


I need a bit of help changing a tab-delimited document (.tsv file) into a
special format so I can import it into our trouble ticket system (RT).

The .tsv file has 23 columns, and 108 entries.  I am going to use a
spreadsheet style to reference the values (i.e. A1 for the 1st column, 1st
entry - B1 for the 2nd column, 1st entry)

I need to get it into a text file that would look like this:

===Create-Ticket: ticket1
Queue: <B2>
Subject: <C2>
Status: <D2>
TimeEstimated: <E2>
TimeWorked: <F2>
TimeLeft: <G2>
Priority: <H2>
FinalPriority: <I2>
Owner: <J2>
Requestors: <K2>
Due: <L2>
Told: <M2>
Created: <N2>
Resolved: <O2>
CustomField-10: <P2>
CustomField-11: <Q2>
CustomField-12: <R2>
CustomField-13: <S2>
CustomField-14: <T2>
CustomField-5: <U2>
CustomField-7: <V2>
CustomField-8: <W2>
CustomField-9: <X2>

===Create-Ticket: ticket1
Queue: <B3>
Subject: <C3>
Status: <D3>

on, and on, and on.....



Knowing that (most likly) the suggestion will come back as a PERL
solution... I would also like to request any suggesting for a good PERL
book.  PERL for dummys kind of thing (My coding/scripting skills are limited
to bash and HTML, not exactly very fancy stuff :-)  )

Thanks in advance for your time.

--
http://gentgeen.homelinux.org

#############################################################
 Associate yourself with men of good quality if you esteem    
 your own reputation; for 'tis better to be alone then in bad 
 company.        - George Washington, Rules of Civility
_______________________________________________
wplug mailing list
wplug at wplug.org
http://www.wplug.org/mailman/listinfo/wplug



More information about the wplug mailing list