%% Append Data to Bottom of Table
% Append data as a new row to the bottom of a table with existing data.
% Create a table.

InsectSpecies = {'Monarch Butterfly';'Seven-spot Ladybird';'Orchid Mantis';...
    'American Bumblebee';'Blue Dasher Dragonfly'};
InsectOrder = {'Lepidoptera';'Coleoptera';'Mantodea';'Hymenoptera';'Odonata'};
InsectFamily = {'Nymphalidae';'Coccinellidae';'Hymenopodidae';...
    'Apidae';'Libellulidae'};
PredatoryInsect = logical([0;1;1;0;1]); 

T = table(InsectSpecies,InsectOrder,InsectFamily,PredatoryInsect)

% Write the table T to a text file called InsectCollection.txt.

writetable(T,'InsectCollection.txt','WriteRowNames',true) 

% Create new data in the form of a table to add to the existing table.

newInsect = table({'Red-banded leafhopper'},{'Hemiptera'},{'Cicadellidae'},logical([0]))

% Append newInsect to InsectCollection.txt using the 'WriteMode','Append' name-value pair argument.

writetable(newInsect,'InsectCollection.txt','WriteMode','Append',...
    'WriteVariableNames',false,'WriteRowNames',true)  

% Read the table back into the workspace.

readtable('InsectCollection.txt')

% Copyright 2019 The MathWorks, Inc.