Does anyone know how to solve my problem?
Im able to import a Excel File into my Matlab GUI, the problem is the file exist in a few sheets combined together (example: monthly data). I'm trying to import the data from different sheets on the excel file but was not able to (anything from the 2nd sheet i can't import). Anyone knows of a code to import the data?
I guess you used xlsread in order to read data from an XLS file. If you do not add arguments to the function, it will only read the first worksheet. Please check the xlsread documentation by typing doc xlsread in your matlab session.
You can see that you can specify the worksheet with the following code :
num = xlsread(filename,sheet)
Related
How can I import a specific sheet in an Excel file into Matlab (as an array or table)?
Apparently xlsread is not recommended in the official documentation. However, their recommended method of readtable does not allow you specify a sheet name (I think? perhaps missed it?)
Using test = xlsread('myfile.xlsx', 'my sheet name') seems to work fine in my case, except it skips column headers. Is there a way to keep headers?
Using test = readtable('myfile.xlsx') keeps the headers but just automatically imports the first sheet.
On Windows, Matlab R2018a.
By default, readtable reads the first sheet. You can specify sheet number/name as well to read your desired sheet.
test = readtable('myfile.xlsx','Sheet','my sheet name');
Please read the documentation for more details.
I tried using openpyxl library to read and write data in excel. But later did I know that I need to manipulate an excel binary worksheet. openpyxl doesn't support xlsb.
Is there any other libraries that I can use to be able to read and write data in xlsb without changing any format of the excel?
The requirement is, as much as possible:
Append data at the last row (Don't rewrite the whole data as it will affect the runtime of script).
Don't convert the xlsb
Thank you in advance.
I used xlwings library. Image will be kept and I can work with .xlsb.
I am trying to access an excel file using python for my physics class. I have to generates data that follows a function but creates variance so it doesn’t line up perfectly to the function(simulating the error experienced in experiments). I did this by using the rand() function. We need to generate a lot of data sets so that we can average them together and eliminate the error/noise creates by the rand() function. I tried to do this by loading the excel file and recording the data I need, but then I can’t figure out how to get the rand() function to rerun and create a new data set. In excel it reruns when i change the value of any cell on the excel sheet, but I don’t know how to do this when I’m accessing the file with Python. Can someone help me figure out how to do this? Thank You.
Excel formulas like RAND(), or any other formula, will only refresh when Excel is actually running and recalculating the worksheet.
So, even though you may be access the data in an Excel workbook with Python, you won't be able to run Excel calculations that way. You will need to find a different approach.
The data exists of Bank statements including descriptions. I've imported these bank statements from a .swi file into an excel file, which worked fine.
When imported to matlab with the:
[NUM, TXT, RAW] = xlsread(filename)
function, it worked but it did give the following warning:
Warning: Could not start Excel server for import, 'basic' mode will be used.
Refer to
HELP XLSREAD for more information.
In xlsread at 186
Which is strange because the university computer i'm using has excel. After importing, the data does show itself correctly in the RAW-matrix only it has high comma's in each cell, for example:
'C150331EUR000000001352,14'
When trying to make a function work with the data it does not function properly with a range of different errors, while the functions i'm using do work on random teststrings.
Anyone any idea how to make this data work?
thanks for looking at this problem, I hope I can get some help, as I am not very experienced with VBA syntax in excel.
Background:
I will be receiving a large (1000's of lines) CSV file that will contain data entries of various lengths. Each line will begin with a code (eg, 01, 02,..., 50) and have a series of data entries following it based on that code.
So, for example
01,data,data,data
01,data,data,data
02,data,data,data,data
etc...
I need to import all of this data into an existing excel workbook that already has separate tabs and headers created to correspond with the data type.
What I believe needs to be done, is to import the csv to a new, blank sheet, then run a vba program to check the data code, and move the line to the corresponding tab. I would also like to preserve the formatting on the destination sheet.
Ultimately, what I think I need is a VBA program to read the code cell, and move the line to an existing tab based on that code, and loop through the whole column.
Most of the existing solutions I have found involve the creation of new tabs, but I wish to parse the raw data into existing tabs with headers and formatting. I am aware this may require me to manually type in the code and destination tab names in the program's logic - That will not be an issue as long as I have a base to start with!
Thanks again for your help, and let me know if I can provide any more information.