User Profile

Collapse

Profile Sidebar

Collapse
Iris83
Iris83
Last Activity: Mar 9 '07, 10:56 AM
Joined: Feb 28 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Iris83
    replied to Processing a Data Structure
    in Perl
    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...
    See more | Go to post

    Leave a comment:


  • Iris83
    replied to Processing a Data Structure
    in Perl
    The syntax is indeed {1} in my script but it doesn't work!

    so any tips would be appreciated!
    See more | Go to post

    Leave a comment:


  • Iris83
    replied to Processing a Data Structure
    in Perl
    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>)
    ...
    See more | Go to post
    Last edited by miller; Mar 1 '07, 04:44 PM. Reason: Code Formatting

    Leave a comment:


  • Iris83
    replied to Processing a Data Structure
    in Perl
    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
    ...
    See more | Go to post

    Leave a comment:


  • Iris83
    started a topic Processing a Data Structure
    in Perl

    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

    ...
    See more | Go to post
    Last edited by miller; Feb 28 '07, 04:03 PM. Reason: Code tag

  • Iris83
    replied to Parsing a CSV file into a Hash
    in Perl
    Thanks this works!
    See more | Go to post

    Leave a comment:


  • Iris83
    started a topic Parsing a CSV file into a Hash
    in Perl

    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');...
    See more | Go to post
No activity results to display
Show More
Working...