Solved

perl or Simple Excel macro

Posted on 2014-03-20
6
148 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

746 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

13 Experts available now in Live!

Get 1:1 Help Now