Is it possible write on txt file and then convert it to csv?

조회 수: 1 (최근 30일)
Anita Coletta
Anita Coletta 2020년 10월 30일
편집: Gouri Chennuru 2020년 11월 3일
Hello everybody!
It's me again; today I have new problem: we're trying to add 3 char array, because we need it for another software. We try with this part of code:
text={'Start:,0,';'Length:,1200,';'Sample Rate:,100,'};
sign=cellstr(text);
sign2=num2cell(sign1(:,1));
SIGN={[sign;sign2]};
SIGN2=cell2table(SIGN{1,1});
SIGN3=table2array(SIGN2);
writecell(SIGN{1,1},'output.csv')
But there's a problem with txt file, because there're ' " ' and they don't run the software that we need to use.
We've tried with another code
sign1=0.00001*sign1;
dlmwrite('NEW.txt',sign1,'precision','%.f,');
load NEW.txt;
NEW=NEW(1:4096);
writematrix(NEW,'output1.csv');
but, in this case, we don't know how to insert 3 char rows in txt file.
Can someone help us, please?
  댓글 수: 2
Mathieu NOE
Mathieu NOE 2020년 10월 30일
hello Anita
sorry I don't understand your problem.
But there's a problem with txt file, because there're ' " ' and they don't run the software that we need to use.
you want to add 3 char (what ? the ' " ' ? ) array where ? in the file name ? in the csv file ?
what are the dimensions of your input data ? (sign1)
would be helpfull if you can define :
1/ your inputs : sign1,
2/ a template of how you want to have your output data / output file organized...
Star Strider
Star Strider 2020년 10월 30일
The table approach is appropriate and preferable. Keep it that way!
Create the table and then use writetable to write it to whatever sort of file you want.

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

채택된 답변

Gouri Chennuru
Gouri Chennuru 2020년 11월 3일
편집: Gouri Chennuru 2020년 11월 3일
Hi,
You can maintain the table and you can use the “writetable” function in MATLAB to write the table to a comma delimited text file.
Hope this Helps!

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by