how can I convert comma with semicolan and then again point with comma for a multiple csv files?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohammed Cha
am 6 Dez. 2020
Kommentiert: Ameer Hamza
am 6 Dez. 2020
Hello Matlab Helpers,
I have some csv files (english) which i need to convert in german version. I have not done it before. Can anyone help me please?
What i need to do is
I want to convert first 1. comma with semicolan and then again
2. point with comma for same csv file
and these same ruling for all other csv files and want to save it with csv. format.
My trial but getting error that *Invalid file identifier*:
P = 'C:\Users\Cha\Desktop';%relative/absolute path to the folder where the files are saved';
S = dir(fullfile(P,'*.csv'));
for k = 1:numel(S)
myfilename=sprintf('scope_%d.csv',k);
fidi=fopen(myfilename,'rt')
mydatacoma=textscan(fidi,'%s%s','CollectOutput',1);
fclose(fidi)
mydataadot{k}=strrep(mydatacoma,',',';');
myfinal{k}=strrep(mydataadot{1},'.',',');
end
Thank you very much in advance
Regards,
Cha
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 6 Dez. 2020
Try this
str = fileread('scope_0.csv');
str = replace(str, {',', '.'}, {';', ','});
f = fopen('outfile.csv', 'wt');
fprintf(f, '%s', str);
fclose(f);
5 Kommentare
Ameer Hamza
am 6 Dez. 2020
You can process a sequence of file in MATLAB like this: https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!