Link to home
Create AccountLog in
Avatar of Michał Pijus
Michał Pijus

asked on

How to create hash of arrays in perl from excel files ?

The format of input file is ( two columns in excel):

A1;A2
A1:B3
A1:C3
A2:C3
A2:D1

I'd like to get (make) something like that:

A1=>[A2,B3,C3];
A2=>[C3,D1];

No Idea ho to do it ;(
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Beautiful work, wilcoxon!  I tested it on Windows and it worked for me.  Take a pay rise, and have the rest of the week off.

Michał, what kind of Excel files are you wanting to process?  XLS or XLSX?
If you want to process XLSX then, in theory, you should be able to just change "use Spreadsheet::ParseExcel" to "use Spreadsheet::ParseXLSX" in the code I provided.  Note though that I haven't actually used ParseXLSX (the syntax for Spreadsheet::XLSX code is a little different (it is compatible with an older version of Spreadsheet::ParseExcel)).
Thanks wilcoxon.
I changed the 2 occurrences of "Spreadsheet::ParseExcel" in your script to "Spreadsheet::ParseXLSX" and it worked for an XLSX file, just like a bought one.

Michał, what kind of Excel files are you wanting to process?  XLS or XLSX or both?  If both, wilcoxon's code could be easily modified to handle that, but you might be able to do that yourself.
Hi Michał,

I understand that this is your first question with Experts Exchange, so are you aware that to accept someone's answer, you don't just click the thumbs-up button.  You have to click the button under their post, near the right, to accept their answer, then follow the prompts.  Otherwise, the expert doesn't earn any points for their hard work.
Avatar of Michał Pijus
Michał Pijus

ASKER

Thank you wilcoxon. It works !