1753466 Members
4623 Online
108794 Solutions
New Discussion

Perl help

 
SOLVED
Go to solution
Pat Tom
Occasional Contributor

Perl help

Hi,

I am writing a perl script that reads the attached csv file which has 2 columns of ID and date.

The script should output the rows that have same IDs for different dates. The output for the attached input should be:

69 20061224
69 20061226
69 20061228
300 20061223
300 20061228
550 20061229
550 20070102

In my script i have a hash that stores the value of the ID and the date but somehow I am not able to figure the logic for matching the rows for the same ID.

Can anyone please help

Thanks
Pat
1 REPLY 1
H.Merijn Brand (procura
Honored Contributor
Solution

Re: Perl help

> perl -ne'($id,$date)=split/,/,$_;push@{$h{$id}},$_}END{for(values%h){@$_<2 and next;print for@$_}' xx.csv
69,20061224
69,20061226
69,20061228
550,20061229
550,20070102
300,20061223
300,20061228

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn