I have 2 datasets one containing data like this
11,1,B
12,2,B
13,3,T
21,4,T
22,5,T
From this data i want the 2nd row to be the keys in the hash and the 3th row the values.
my 2nd data set looks like this
1 1 1 0 0
2 1 0 1 1
3 1 0 1 1
5 1 0 0 0
for example if the first key which is 1 exists and the value is B i want to reverse...
User Profile
Collapse
-
The syntax is indeed {1} in my script but it doesn't work!
so any tips would be appreciated!Leave a comment:
-
Accessing The keys and values in a Hash
Hi i want to use the keys and values of a hash to compare them with other files. But i can't acces them.
This is my code i hope somone can help!
Code:my %hash; while( <Data> ) { @elements = split /,/, $_; if( $elements[1] ne '' ) { $hash{ $elements[1] } = $elements[2]; } } while ($data = <Dataset>)
Leave a comment:
-
Thank you for your help. I tried it like you said it is a hash so this is what i used but im not getting any output! I hope you can help me figure out what i should do!
Code:while ($data = <Dataset>) { if (exists $hash{1]} { if ($hash{2} eq 'B') { for ($i = 0; $i < length($data); $i++) { $characterString = substr($data, $i, 1); $newCode = $characterString; if ($characterString
Leave a comment:
-
Processing a Data Structure
Hi,
I have a question about converting some of the data in my dataset but leave some data the way it is.
I have a hash and if the key is present and the Value of the Hash equals B it should convert these number but if B is not present the data should remain the same.
my output is that all the data is converted not in the only the cases were B is present.
This is the script i have
... -
-
Parsing a CSV file into a Hash
Hi,
Im a new to perl and i hope there are people here that can help me!
I have a realy large file like this.
1,12,T,
2,13,B,
3,14,T,
4,15,B,
I want to use the 2nd and 3th column and put it into a hash like
with the 2nd column being the keys and the 3th column being the values.
This is what i have but i doesn't work!
open (data, 'data.csv');...
No activity results to display
Show More
Leave a comment: