Converting .txt file to .xls format with Matlab as the interface.
Show older comments
previously, I converted a text file containing data as follows;
"06-11-2013","13:01:00","00","00","00","1","1","0","5","0","0","0","0","6"
this has delimiters = ' "," '
i used import data with delimiter ',' (comma) and used cell2csv() function then wrote it back to .xls and it worked perfectly. But now, I have a different issue. I have a .txt file with data as follows;
15:28:43#00348#048.1#053.3#00325#046.2#051.3#00000#000.0#000.0 which has only '#' as the delimiter. I tried using the same method. But i get an error.
??? Cell contents reference from a non-cell array object.
Error in ==> cell2csv at 43 var = eval(['cellArray{z,s}']);
Error in ==> newall_Cell at 20 cell2csv(fileName, cellArray, separator, excelYear, decimal)
------------------------------------------------ the code i used is as follows ------------------------------------------------- filename1 = 'ABC.txt';
delimiterIn1 = '#';
A = importdata(filename1,delimiterIn1);
fileName = 'XYZ.csv';
cellArray = A;
separator = ',';
excelYear = '2003';
decimal = '.';
cell2csv(fileName, cellArray, separator, excelYear, decimal)
% the cell2csv function is long so i am not giving it here.
% by Sylvain Fiedler, KA, 2004
% updated by Sylvain Fiedler, Metz, 06
% fixed the logical-bug, Kaiserslautern, 06/2008, S.Fiedler
% added the choice of decimal separator, 11/2010, S.Fiedler
C = xlsread('XYZ.csv');
xlswrite('ABC.xls',C);
------------------------------------------------------
Need help on this please. Thanks
4 Comments
Cedric
on 8 Aug 2013
Why using CSV as an intermediary step towards XLS(X), when you could export directly as XLS(X)? Also, why not importing the text file directly with Excel, setting the appropriate delimiter in the import wizard?
Kamalanathan Ganesan
on 9 Aug 2013
Ara
on 19 Sep 2020
Hi Cedric,
Can you please answer my question, too?
Accepted Answer
More Answers (0)
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!