Solved

perl or Simple Excel macro

Posted on 2014-03-20
6
149 Views
Last Modified: 2014-05-26
Hi,

Need help on a data migration.

Reversal of this question.

http://www.experts-exchange.com/Programming/Languages/Scripting/Perl/Q_28330561.html

Input:
ID      Product Details
2500      PROD894,PROD888,PROD900,PROD23,PROD17
2501      PROD390
2502      PROD388
2503      PROD440,PROD433,PROD475
Output:      
ID      Product Details
2500      PROD894
2500      PROD888
2500      PROD900
2500      PROD23
2500      PROD17
2501      PROD390
2502      PROD388
2503      PROD440
2503      PROD443
2503      PROD475

Thanks
0
Comment
Question by:magento
  • 4
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 39944530
perl -lane 'BEGIN{local $\;print"".<>}print "$F[0]\t$_" for split/,/,$F[1]' < Input > Output
0
 
LVL 5

Author Comment

by:magento
ID: 39944534
Ozo,

Getting the below error. Pls advice

C:\Expert-Exchange\perl>perl -lane 'BEGIN{local $\;print"".<>}print "$F[0]\t$_"
for split/,/,$F[1]' < perl.csv > order.csv
> was unexpected at this time.

Open in new window

0
 
LVL 84

Expert Comment

by:ozo
ID: 39944536
DOS shell would use different quotes
perl -lane "BEGIN{local $\;print''.<>}print qq'$F[0]\t$_' for split/,/,$F[1]" < Input > Output
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Author Comment

by:magento
ID: 39944567
I tried the above, it shows only one line.

See input and output attached,
perl.csv
order.csv
0
 
LVL 84

Expert Comment

by:ozo
ID: 39944577
Your example looked like
ID      Product Details
2500      PROD894,PROD888,PROD900,PROD23,PROD17
2501      PROD390
2502      PROD388
2503      PROD440,PROD433,PROD475

But your perl.csv looks like
1,"0,0,0,0,0"
2,20
3,20
4,"23,23,27"

What should the output be for the latter?
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39944585
maybe you want something like
perl -F, -alne "s/\42//for@F;$F=shift@F;print qq'$F,$_'for @F" < perl.csv
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now