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 件のコメント

madhan ravi
madhan ravi 2019 年 9 月 18 日
pruth
pruth 2019 年 9 月 18 日
編集済み: pruth 2019 年 9 月 18 日
yes but i feel i dint ask the question correctly. and can not delete the old question too ! however i couldnt solve the prblem yet ! i would really apriciate if you could help ! thank you !
Geoff Hayes
Geoff Hayes 2019 年 9 月 18 日
pruth - do you just have one file? If so, can you do this manually instead of using MATLAB?
pruth
pruth 2019 年 9 月 19 日
no sir, i have 100's of files like this . i can not do it manually !

サインインしてコメントする。

 採用された回答

pruth
pruth 2019 年 9 月 19 日

0 投票

this worked for me ! thank you all !
after reading the csv file i converted it into mat file 'a' and used this further code .
M = length(a(:,1))
dlmwrite('test.csv',M,'delimiter',',')
N = a;
dlmwrite('test.csv',N,'delimiter',',','-append');

その他の回答 (1 件)

Sebastian Körner
Sebastian Körner 2019 年 9 月 18 日

1 投票

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

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

タグ

質問済み:

2019 年 9 月 18 日

回答済み:

2019 年 9 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by