Hi Everybody,
I've tab delimited data as below:
Retid State Rate
25 NJ 7.000
26 NJ 7.000
40 IL 9.750
40 IN 7.000
40 MI 6.000
40 WI 5.500
44 CT 6.000
50 NJ 7.000
87 VA 4.500
I want all unique Retid, comma seperated State & State corresponding to that Retid. Later I would need to add this data into different xml file by comparing Retid (Which is already in other file). I think using hashes would be OK as I don't want to read file everytime (else script will run longer), but not sure how to do this! Could anyone please suggest?
I've tried something like below:
open(IN, $taxFile) || die "$taxFile couldn't be opened $@\n";
while(<IN>) {
chomp;
@line = split("\t");
$sid = $line[0];
$sidHash{$sid}{state} = $line[1];
$sidHash{$sid}{rate} = $line[2];
}
Output file would be as below, where I'll add these 2 tags i.e. state & rate. Rest tags were read & printed from different file.
<RetId="40">
<name>xyz</name>
<url>http://www.xyz.net</url>
<type>CPC</type>
<logoUrl/>
<ntParentAcct>5403020</ntParentAcct>
<feedCount>1</feedCount>
<feedNumbers>1</feedNumbers>
<state>IN, MI, WI</state>
<rate>7.000, 6.000, 5.500</rate>
</RetId>