Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How Best to Handle Data

by Comment (Novice)
on Sep 24, 2010 at 00:48 UTC ( [id://861704]=perlquestion: print w/replies, xml ) Need Help??

Comment has asked for the wisdom of the Perl Monks concerning the following question:

Thank you all in advance for your help!

I am having a difficult time determining the best way to handle my data and I know this will be any easy problem for the more Perl-literate. I also realize that this problem could be solved with something other than Perl, but I only know Perl at the moment. I have outlined my situation below:

Goal- Calculate the euclidean distances between all (x,y,z) coordinates within and between multiple data sets. Each point in a data set has its (x,y,z) coordinates stored within an excel file. For example, the coordinates for D1, D2,and D3 are found in D.xls and the coordinates for E1,E2, E3, and E4 are found in E.xls. To complicate matters, the number of points in the files and the number of files can be different from day to day.

Where I'm at Now- I am able to gather all of the files names that are needed for the analysis. I was hoping to use Spreadsheet::Read to pull the data into a hash table (%H1). The keys of the hash table will be the file names and the values would be another hash table (%H2)...if that's possible? The keys of %H2 would be the point ID (ex D1 or D2) and the values of %H2 would be the (x,y,z) coordinates read by Spreadsheet::Read. The problem is that I'm not exactly sure how that works. Any help you could provide would be extremely helpful!

Many Thanks!

Replies are listed 'Best First'.
Re: How Best to Handle Data
by bellaire (Hermit) on Sep 24, 2010 at 01:15 UTC
    Sure it's possible. I recommend taking a look at perldsc for an overview of data structures in Perl. One thing to keep in mind is that your second-level hash doesn't need to be named, as it is contained in the outer hash and keyed on the filenames. Per your example, you could do something like this (note that the Spreadsheet::Read documentation states that ReadData returns a array reference, not a hash):
    use Spreadsheet::Read; my %H1; my @filename_list = qw(D.xls E.xls); for my $filename (@filename_list) { $H1{$filename} = ReadData($filename); } my $example = $H1{'D.xls'}->[1]->{A1}; # $example now has the value of + # cell A1 of sheet 1 of D.xls
Re: How Best to Handle Data
by ww (Archbishop) on Sep 24, 2010 at 01:07 UTC
    "The problem is that I'm not exactly sure how that works."

    As someone once said, "ignorance can be cured." In fact, that's one of the Monastery's missions. You can read all about "how (Spreadsheet::Read) works"

    You may also wish to familiarize yourself with the local guidelines -- see On asking for help and How do I post a question effectively?.

    ...and, just BTW, it may be worth considering Spreadsheet-ParseExcel.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://861704]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-19 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found