How to append data or values to an existing .csv file??
조회 수: 6 (최근 30일)
이전 댓글 표시
hi..suppose i have a .csv file named csvfile.csv.And it has the values as follows:
23 45
69 84
48 78
12 34
so it has two colums.Now wat i need to do is to add values staring from the 3rd colum with out deleting the values in the 1st and 2nd colums..How can i do this...??Any one plz help..!!
댓글 수: 0
답변 (1개)
nick
2025년 4월 17일
Hello Manoj,
To add a third column to an existing CSV file in MATLAB without deleting the values in the first and second columns, you can follow these steps:
% Step 1: Read the existing CSV file
existingData = csvread('file.csv');
% Step 2: Create the new column data (example data)
newColumn = [100; 200; 300; 400]; % Make sure it has the same number of rows
% Step 3: Combine the existing data with the new column
updatedData = [existingData, newColumn];
% Step 4: Write the updated data back to the CSV file
csvwrite(updatedData, 'file.csv');
Kindly refer to the documentation by executing the following command in MATLAB Command Window to know more about 'csvread' and 'csvwrite' :
doc csvread
doc csvwrite
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!