convert xls to txt without column names

조회 수: 10 (최근 30일)
sai prasanna sai prasanna m s
sai prasanna sai prasanna m s 2022년 11월 17일
답변: Aritra 2022년 11월 21일
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
sai prasanna sai prasanna m s
sai prasanna sai prasanna m s 2022년 11월 17일
Sorry, I meant xls file, as I had mentioned in my title. I have edited my question now.
Stephen23
Stephen23 2022년 11월 17일
Use READMATRIX and WRITEMATRIX.

댓글을 달려면 로그인하십시오.

답변 (1개)

Aritra
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.
You can set the WriteVariableNames indicator to false in the writetable(T) function.
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

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by