How to append data or values to an existing .csv file??
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
nick
il 17 Apr 2025
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 Commenti
Vedere anche
Categorie
Scopri di più su MATLAB Report Generator in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!