473,410 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

Having trouble with Spreadsheet::Read hash

Hey everyone. I'm using Spreadsheet::Read to grab data from an excel .xls file and I can't figure out how to loop through the hash and display the data. Using print works but I would like to print column A1 through A100 without having to manual type them all out. I tried a lot of different things so any help would be really appreciated. Here is the code I've got so far:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use Spreadsheet::Read;
  5. use Data::Dumper;
  6.  
  7. my $xls = ReadData ("test.xls");
  8.  
  9. print $xls->[1]{'A1'};
  10. print $xls->[1]{'A2'};
  11. print $xls->[1]{'A3'};
  12.  
  13. exit;
Jan 21 '10 #1
2 3200
toolic
70 Expert
Try this:

Expand|Select|Wrap|Line Numbers
  1. for my $cell (map { "A$_" } 1 .. 100) {
  2.     print $xls->[1]{$cell};
  3. }
  4.  
Jan 21 '10 #2
Yessssss, Thank you so much!

I will be sure to come back here if I have any more questions. The if loop helped me figure out how to check if any cells contain the word "test":

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use Spreadsheet::Read;
  5. use Data::Dumper;
  6.  
  7. my $xls = ReadData ("test.xls");
  8.  
  9.  
  10. for my $cell (map { "A$_" } 1 .. 100) {
  11. $_ = $xls->[1]{$cell};
  12.  
  13.     if (/test/) {
  14.         print "found \"test\" in cell: $cell\n";
  15.     }
  16. }
  17.  
  18. exit;
Jan 23 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Brad Tilley | last post by:
Is there a way to make urllib or urllib2 read all of the pages on a Web site? For example, say I wanted to read each page of www.python.org into separate strings (a string for each page). The...
1
by: Matt | last post by:
I want to open a file (Excel spreadsheet) read-only using JavaScript. Can someone tell me if/how this can be done? Thanks in advance, Matt
40
by: Abby | last post by:
My .dat file will contain information like below. /////////// First 0x04 0x05 0x06 Second 0x07
2
by: siaj | last post by:
Hi.. I m just trying to learn using XML file as a datastore. I am reading a dataset from a XML file and then trying to update the XML file with some changes in the dataset. My code is as...
3
by: Sean Liong via .NET 247 | last post by:
Hi, Is there any possibilities Read/Write a the storage file from a client system from a ASP.net web application? I think using the activeX component able to achieve this but is there any other...
1
by: marfi95 | last post by:
Is there a way to make the internetreadfile function read records that are terminated by newlines instead of reading into a buffer. It would make it much easier for me to process. I suppose I...
4
by: Cyron | last post by:
Hello Friends, When I make a call to NetworkStream.Read(byte buffer, int offset, int size) I have found that this method will block until size bytes have been read or the connection is closed. ...
22
by: pbd22 | last post by:
Hi. I am building a custom telnet interface and my problem is that I want to read the user input along with the previously written stream. Right now I am logging the user. I have Login:...
10
by: Zytan | last post by:
I have a TcpClient. I set the read/write timeouts at 1 minute (in milliseconds). I get a NetworkStream from it and confirm the timeouts still exist. I do a NetworkStream.Write() and then a...
2
by: Zytan | last post by:
I just had the problem occur again, with NetworkStream.Write() doing its thing with a timeout... and it just sits and waits and waits and waits... it never times outs. So, I shut the server down...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.