export CSV file with timestamp in filename
4 views (last 30 days)
Show older comments
alexandra kaufhold
on 2 Feb 2015
Commented: Star Strider
on 2 Feb 2015
I want to export some data using writetable into a .csv file but I also want a timestamp in the name of the .csv file. I have been able to export the data to a .csv file and I have been able to export the data with the timestamp but ONLY as a .txt file. Any advice??
0 Comments
Accepted Answer
Star Strider
on 2 Feb 2015
I’m not certain exactly what you want, but this will get you started:
filename = sprintf('CSV File %s.csv', datestr(now));
produces:
filename =
CSV File 02-Feb-2015 10:16:58.csv
You can specify the format of the timestamp with the ‘formatOut’ parameter of datestr, for example:
filename = sprintf('CSV File %s.csv', datestr(now, 'dd.mm.yyyy HH:MM'))
produces:
filename =
CSV File 02.02.2015 10:20.csv
2 Comments
More Answers (0)
See Also
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!