- Posts: 1
Data Transfer from .xls Files
- rfreesta
- Topic Author
Less
More
31 Jul 2017 09:49 #5601
by rfreesta
Data Transfer from .xls Files was created by rfreesta
Is it possible to read the full contents of .xls files into an array, without having to name the range of cells being read (similar to how csvread can read .csv files to an array)?
We wrote a script that reads spreadsheets containing on-site weather measurements (irradiance, temperature, wind speed), and runs a simulation based on them. However, the on-site weather measurements are in .xls form, and can have a varying number of rows depending on the timeframe chosen for analysis and the measurement interval (there is one row of data per timestamp). Since we couldn't find a way to read the data directly from .xls files, we're currently opening the .xls weather measurements manually in Excel, saving as a .csv, and then running the script using csvread.
Is there a more automated way to do this- can the script read all of the data into arrays directly from the .xls file (without having to manually assign a name in Excel to the range of cells being read), or else can it automatically convert an .xls file to a .csv file?
We wrote a script that reads spreadsheets containing on-site weather measurements (irradiance, temperature, wind speed), and runs a simulation based on them. However, the on-site weather measurements are in .xls form, and can have a varying number of rows depending on the timeframe chosen for analysis and the measurement interval (there is one row of data per timestamp). Since we couldn't find a way to read the data directly from .xls files, we're currently opening the .xls weather measurements manually in Excel, saving as a .csv, and then running the script using csvread.
Is there a more automated way to do this- can the script read all of the data into arrays directly from the .xls file (without having to manually assign a name in Excel to the range of cells being read), or else can it automatically convert an .xls file to a .csv file?
Please Log in or Create an account to join the conversation.
- pgilman
Less
More
- Posts: 5423
31 Jul 2017 11:41 #5602
by pgilman
Replied by pgilman on topic Data Transfer from .xls Files
Hello,
As you note, the LK functions that work with Excel objects can only read and write to single cells
or to ranges of cells if they are named
. You probably already found the example files at the bottom of the Samples page, but here's a link for others who may not have seen it:
sam.nrel.gov
Perhaps you could write a script in Python or some other language to convert the Excel files to CSV before running your LK script -- there are several examples on the web.
Best regards,
Paul.
As you note, the LK functions that work with Excel objects can only read and write to single cells
Code:
xl_get(xl,'a1');
Code:
xl_get(xl,'my_range');
sam.nrel.gov
Perhaps you could write a script in Python or some other language to convert the Excel files to CSV before running your LK script -- there are several examples on the web.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- sogold
Less
More
- Posts: 1
20 Aug 2017 21:41 #5603
by sogold
Replied by sogold on topic Data Transfer from .xls Files
Thanks you Paul Gilman
Please Log in or Create an account to join the conversation.
Moderators: pgilman