Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

perl or Simple Excel macro

Posted on 2014-03-20
6
Medium Priority
?
165 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

609 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