CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...: translate csv format: Edit Log



mgpg
Novice

Feb 15, 2008, 3:26 PM


Views: 4708
translate csv format

I hope somecan help me to convert the following csv to the desired output.

Input
  • Each Row has the following columns - Component, Summary, Data, Priority.
  • Each row may span multiple lines, row is delimited by a ^M
  • All strings. Priority is P1, P2, etc.
  • Data is kind of weird. It is in quotes and has enumerated steps (please see sample below). It may contain commas! But not quotes.
  • A comma is a delimted by comma (see exception above for Data)
  • I cannot change the csv - generated by some tool.


Sample Input

Component1,Summary2 ,"1.Step1
2. Step2 details
3. Step3 details

",P2^M

Component2,Summary1,"1. User1 does this
2. User2 does that
3. User1 does something else

",P2^M

Component2,Summary2 ,"1.Step1
2. Step2 details
3. Step3 details

",P1^M

Desired Output

foreach component {

print priority

foreach step in Data { print <step-number>## step }

print summary\n

}

as well as

foreach priority {

print component

foreach step in Data { print <step-number>## step }

print summary\n

}



I hope someone can help me here. Thanks a bunch :)

(This post was edited by mgpg on Feb 15, 2008, 3:27 PM)


Edit Log:
Post edited by mgpg (Novice) on Feb 15, 2008, 3:27 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives