How to convert table to a csv file and save it in a remote location?

5 views (last 30 days)
Hi all,
I have a 1x72 table (attached) that I would like to convert to a csv file and save in a specific folder location.
I can save the table as a mat file to my desired location and with the desire name (loop over multiple files) in the following way but not sure how to apply it when saving the table to the csv file. Can you help please?
save(fullfile([DotFolder(1:end-31) '_Stats'],[all_files(k).name(1:end-8) '_Stats.mat']), 'Stats');
For example when I try this:
writematrix([DotFolder(1:end-31) '_Stats'],[all_files(k).name(1:end-8) '_.csv']), Stats;
results in saving the csv with the desired name but in the folder where the code is located and the content of the file is just the location of the folder, rather than the data from the table

Accepted Answer

Jan
Jan on 23 Feb 2022
Folder = 'D:\Your\Folder';
File = [all_files(k).name(1:end-8) '_.csv'];
writematrix(Stats, fullfile(Folder, File));

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!