Writing Multiple CSV files
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Curious Mind
el 10 de Nov. de 2017
Editada: per isakson
el 10 de Nov. de 2017
I have a dataset which has about 20 spectra. All 20 spectra share the same x-axis. So I have 21 columns, column 1 representing the x-axis and columns 2 to 21 representing the y values. I want to save the data 20 separate .csv files. Csvwrite just combines all the data into one large csv files which is not what I want. I want a code that can save cloumn 1 and 2 separately, 1 and 3 separately, 1 and 4 separately and so on till column 1 and 21 so that in the end I will have 20 separate csv files each having column 1 as the x-axis and the corresponding y column as y-axis.
Look forward to hearing from someone and I would really appreciate it.
Thanks.
5 comentarios
per isakson
el 10 de Nov. de 2017
Editada: per isakson
el 10 de Nov. de 2017
- M is your dataset with 21 columns
- sprintf( 'y%d.csv', jj ) creates a filename
Respuesta aceptada
KSSV
el 10 de Nov. de 2017
A = rand(10,11) ;
%%Write each colum to different files
for i = 2:size(A,2)
filename = ['column',num2str(i),'.csv'] ;
csvwrite(filename,A(:,[1 i]))
end
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!