convert xls to txt without column names
8 次查看(过去 30 天)
显示 更早的评论
I am trying to convert a set of xls files into txt files.
I do not have any names for the columns. But the converted text files have the column names appearing as var1 var2 so on...
I just want to copy the data from xls file to txt file without any column name, with space as delimiter.
Current output:
var1 var2 var3
11 12 13
21 22 23
31 32 33
Output that I want:
11 12 13
21 22 23
31 32 33
I am trying with the following code:
files = dir('*.xls');
for i=1:length(files)
data=readtable(files(i).name)
[filepath,names,ext] = fileparts(fullfile(pwd,files(i).name));
writetable(data,names, 'Delimiter',' ');
end
3 个评论
回答(1 个)
Aritra
2022-11-21
Hi,
As per my understanding, you are trying to copy the data from ‘.xls’ file to ‘.txt’ file without any column headings and having space as delimiter.
files = dir('*.xls');
for i=1:length(files)
data=readtable(files(i).name);
[filepath,names,ext] = fileparts(fullfile(pwd,files(i).name));
writetable(data,names, 'Delimiter',' ','WriteVariableNames',0);
end
For detail, please see this MathWorks documentation below for more information on ‘writetable’: https://in.mathworks.com/help/matlab/ref/writetable.html
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!