Solved

perl or Simple Excel macro

Posted on 2014-03-20
6
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 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.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

691 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