i want to read text and numbers from an excel file. when i write the code as below it can not read the text data from excel file. how can i fix it? thank for taking your time.
data = xlsread('normalize.xlsx');
the picture of excel file is here:
and the picture of data that created from the code is hear:
'xlsread' and 'csvread' are both for reading numeric data in MATLAB. If you are on a Windows platform and have Microsoft Excel installed, you can use the following syntax with 'xlsread' to read your data into two cell arrays:
[num_data string_data] = xlsread('normalize.xlsx');
You will have the text column in your data in the string_data array. The corresponding column in num_data will still have NAN.
Related
I am using powershell to read data from a .xls file. All goes well, no need to display the code. But I have an issue that I have no idea how to solve.
Some columns in the excel are not wide enough to display their data:
In reality:
2016.04.01
As the column is displayed when opening the file:
########
When I am reading from the excel, the cell content I get in powershell is actually ########, not the actual cell content (= a date in this case).
I am reading 1000's of Excel files, all with the same issue. How can I fix this in my code? Is there a flag I need to set that I don't know about?
Any help would be much appreciated!
I am trying to use xlsread functioin to read spreadsheets of 6000x2700 (xlsx file).
I have two questions:
First, when I use something like
[num,txt,~]=xlsread(input_file,input_sheet,'A1:CYY6596')
Matlab keeps showing 'busy' and lose response (while I can open it in excel within 30 seconds).
Is there any solution If I don't want to loop through ranges of the xlsx file? In other word, can I just dump spreadsheet of this size into matlab using xlsread?
Alternatively, Maybe I can use loops to read these files range by range, but I cannot identify the last column of each of the spreadsheets unless I read the whole file first. Therefore, If I cannot identify the last column, it is hard to make loops and do my interpretation on the file.
So My second questions is: Is there a way to identify the last column of the spreadsheet without reading the whole spreadsheet?
Thanks.
EDIT:However, if I run a similar code which only reads first 400 columns ('A1:RY6596') of the spreadsheet, such problem doesn't happen.
which version of matlab you are using?
matlab has a problem to load bix excell file.
convert the excell in csv and use M = csvread(filename).
You can try to convert .xlsx into .xls also.
You can Try the tool in
File Exchange
I have a text file that, when opened in excel, contains columns of data.
I want to use textread in matlab to read a specific column of data.
So, if it were an excel file, I could do:
Data = 'My_data_file.xlsx';
Column_C = xlsread(Data,'C:C');
But how do I do this with a text file?
Thanks!
You will need to know the format of your file. If you have a file that looks like this :
Name,Price,Volume
Sally,120,4.8
John,135,35.49324
You could use the following code :
[~,~,C]=textread('file.txt',%s,%f,%f);
You will insert a ~ to suppress output of certain columns.
Not tested, but you can go through--
help textread;
help csvwrite;
Once you get csv from txt, by
[num, txt, all] = xlsread('My_data_file.csv');
you can get everything inall.
How to get the column, you know well.
I am trying to read data from text file (which is output given by Tesseract OCR) and save the same in excel file. The problem i am facing here is the text files are in space separated format, and there are multiple files. Now i need to read all the files and save the same in excel sheet.
I am using MATLAB to import and export data. I even thought of using python to convert the files into CSV format so that i can easily import the same in MATLAB and simply excelwrite the same. But no good solution.
Any guidance would be of great help.
thank you
To read a text file in Matlab you can use fscanf or textscan then to export to excel you can use xlswrite that write directly to the excel file.
I have the following problem:
1) consider a dataset in Stata whose variables are of type float, double, byte. Observations are all "numbers"
2) I want to save the dataset in .xls format; hence I type in Stata export excel using ".../A.xls"
3) When I open A.xls in Excel, the cells have format "General"
4) I want to load A.xls in Matlab but I get the error Unreadable Excel file: XLS File contains unicode text which is not yet supported
5) If, instead, before going to Matlab, I apply the format "Numbers" to the cells in Excel, A.xls can be easily loaded in Matlab.
Any suggestion on how going directly from Stata to Matlab in this particular case?
With Stata 14, you can save the file as xlsx instead of xls. In this case, the error message on OSX disappears. On Windows, xls seems to work fine as well.
is the problem you having just from xlsread? did you try readtable?