CSharma has asked for the wisdom of the Perl Monks concerning the following question:
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: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.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]; }
<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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CSV file info into xml tags
by poj (Abbot) on Jul 28, 2015 at 08:39 UTC | |
by CSharma (Sexton) on Jul 28, 2015 at 10:14 UTC | |
by 2teez (Vicar) on Jul 28, 2015 at 12:20 UTC | |
by CSharma (Sexton) on Jul 29, 2015 at 11:55 UTC | |
by poj (Abbot) on Jul 29, 2015 at 18:02 UTC | |
by CSharma (Sexton) on Jul 28, 2015 at 10:33 UTC |