How to add a new column to the beginning of a csv file using matlab
13 views (last 30 days)
Show older comments
I have a csv file with 30 rows and 20 columns and I want to write a new column of values at the beginning of the file so that the resuling file has 30 rows and 21 columns using matlab. Any help regarding this would be appreciated.
0 Comments
Answers (1)
Jos (10584)
on 2 Mar 2016
% Step 1 - Read the file
M = csvread(filename)
% Step 2 - Add a column to the data
M = [NewColumn M]
% Step 3 - Save the file
csvwrite(filename, M)
0 Comments
See Also
Categories
Find more on File Operations 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!