how to edit csv file ?
Ältere Kommentare anzeigen
i have this csv file. i want to edit the file and add a number(the value) of total rows in the file at the top without deleting any row .inserting the number !
output should look like
697
98.036,90,72.708,9.9692e+36,9.9692e+36
97.451,90,72.927,9.9692e+36,9.9692e+36
96.9,90,73.135,9.9692e+36,9.9692e+36
.
.
.
97.451,90,72.927,9.9692e+36,9.9692e+36
96.9,90,73.135,9.9692e+36,9.9692e+36
4 Kommentare
madhan ravi
am 18 Sep. 2019
Isn't this the same quesion as https://in.mathworks.com/matlabcentral/answers/480943-how-to-insert-a-single-value-in-the-matrix ?
Geoff Hayes
am 18 Sep. 2019
pruth - do you just have one file? If so, can you do this manually instead of using MATLAB?
pruth
am 19 Sep. 2019
Akzeptierte Antwort
Weitere Antworten (1)
Sebastian Körner
am 18 Sep. 2019
read your file with
A = readtable(yourfile);
then follow this scheme:
A = [8 8 8 8 8 8 ; 7 7 7 7 7 7]; %% example data for your file
[r,c]=size(A);
A = num2cell(A);
B = cell(1,c);
B{1,1} = r;
C = [B ; A];
C is the output you are looking for
Kategorien
Mehr zu File Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!