Convert Excel to csv with exact formatting
Mostrar comentarios más antiguos
Hello,
I have hundreds of Excel files where are stored columns:
x,y,z, temperature
Currently, I open them in Excel, remove first line with description, shift the data 1 line up, change format to "Number" with 9 decimal places for all cells and save it in .csv format (In Excel are 2 options for saving .csv - it should not be UTF-8, the option shown in the attached picture is correct.).
I would like to ask for help with scripting it all in Matlab.
Test files are in the attachment.
I used this script but it didn't produce correct result.
file = dir('*.xlsx'); % make sure your are navigated to the right folder on matlab
s= size(file,1);
for i= 1:s
Data = xlsread(file(i).name);
filename=file(i).name;
filename= filename(1:end-5); % to remove extension from filename
csvwrite([filename '.csv'], Data);
end
;
BR
Mathew
4 comentarios
Les Beckham
el 13 de Feb. de 2024
The "TEST_BEFORE.xls" file that you have attached is not an Excel workbook, it is a plain text file. Also, the code you show appears to be reading .xlsx files rather than .xls files. Are you sure that you attached the right files?
What is it about the results that you are getting that are not the "correct result"?
Mathew Smith
el 13 de Feb. de 2024
Editada: Mathew Smith
el 13 de Feb. de 2024
Cris LaPierre
el 13 de Feb. de 2024
Do you need to keep all the data in separate files, or would it be acceptable to combine all the data into a single csv file?
Mathew Smith
el 13 de Feb. de 2024
Editada: Mathew Smith
el 13 de Feb. de 2024
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


