Link to home
Start Free TrialLog in
Avatar of magento
magento

asked on

perl or Simple Excel macro

Hi,

Need help on a data migration.

Reversal of this question.

https://www.experts-exchange.com/questions/28330561/Need-perl-help.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
Avatar of ozo
ozo
Flag of United States of America image

perl -lane 'BEGIN{local $\;print"".<>}print "$F[0]\t$_" for split/,/,$F[1]' < Input > Output
Avatar of magento
magento

ASKER

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

DOS shell would use different quotes
perl -lane "BEGIN{local $\;print''.<>}print qq'$F[0]\t$_' for split/,/,$F[1]" < Input > Output
Avatar of magento

ASKER

I tried the above, it shows only one line.

See input and output attached,
perl.csv
order.csv
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?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial