in reply to Re^4: Best way to store/access large dataset?
in thread Best way to store/access large dataset?
I'm not really assigning anything. In your example each row from ID's corresponds to exactly one column in Attributes. So I used this to keep the code simple:
1.file.ext Square --> corresponds to column 2 in Attributes
2.file.ext Triangle --> corresponds to column 3 in Attributes
...
16.file.et Square --> corresponds to column 17 in Attributes
There is nothing 'special' about $i and $j. They are just used to traverse the data array and multi dimensional attrs array. In this case I used $j to address each attribute set in attrs. I used $i to address each element in data and each individual attribute of data sub sets inside attrs
To get the ID in the data set, you can make these changes. I'm just adding it to the final result set with the key 'ID' in this case. (Line number followed by: < = remove and > = add):
18 < shift @attrs ; 35 > $subres{ID} = $attrs->[0] ; 36 < for( my $i = 0 ; $i < @{$attrs->[$j]} ; ++$i ) { 36 > for( my $i = 1 ; $i < @{$attrs->[$j]} ; ++$i ) { 38 < ++$subres{ $data->[$i]} ; 38 > ++$subres{ $data->[$i-1]} ;
On line 18 the row ID was removed from the attribute set. So we no longer do that. That means that in the for loop we need to start at index 1 instead of 0 (Line 36). However, the indexing in data has not changed so we have to subtract 1 $i-1 (Line 38).
I'm not sure what you mean with this association. If it is the order of appearance inside data that changes? Then I suggest a small piece of code that alters that order based on column order inside Attributes
What needs to be grouped? Do you have examples?
What do you mean with defined? In you example you show attributes that are binary, they are either 0 or 1? If there is something specific that needs to be done can you try to visualize that?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Best way to store/access large dataset?
by Speed_Freak (Sexton) on Jun 26, 2018 at 23:03 UTC | |
by Veltro (Hermit) on Jun 27, 2018 at 10:26 UTC | |
by Speed_Freak (Sexton) on Jun 27, 2018 at 14:10 UTC | |
by poj (Abbot) on Jun 28, 2018 at 14:32 UTC | |
by Speed_Freak (Sexton) on Jun 28, 2018 at 19:53 UTC | |
by Speed_Freak (Sexton) on Aug 02, 2018 at 14:57 UTC | |
by Speed_Freak (Sexton) on Jun 27, 2018 at 16:56 UTC |