read .csv file, append content to another .csv file

2 ビュー (過去 30 日間)
Kevin Wittkowski
Kevin Wittkowski 2021 年 1 月 7 日
コメント済み: Mathieu NOE 2021 年 1 月 8 日
Hello,
I have two csv files, file1.csv and file2.csv (see attachments).
I want to append all the data -except the header and the first line- in file2.csv to the data already present in file1.csv .
To be clearer,
if file1.csv is
header1,header2,header3
1,2,3
3,4,5
and file2.csv is
header1,header2,header3
3,4,5
6,7,8
9,10,11
I want to get as file1.csv
header1,header2,header3
1,2,3
3,4,5
6,7,8
9,10,11
Thank you in advance :)

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 1 月 7 日
hello
this is it :
data1 = readcell('file1.csv');
data2 = readcell('file2.csv');
[m,n] = size(data2);
data_out = [data1;data2(2:m,:)];
writecell(data_out, 'file_out.csv');
I noticed that your first file ends with time iteration = 4 and and the second file starts also at the same time iteration
maybe one line to be removed if duplicates ?
all the best
  2 件のコメント
Kevin Wittkowski
Kevin Wittkowski 2021 年 1 月 7 日
Thank you Mathieu :)
Mathieu NOE
Mathieu NOE 2021 年 1 月 8 日
You're welcome !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by