writetable
write a table to file
Syntax
writetable(t) writetable(t, filename) writetable(..., Name, Value)
Arguments
- t
table
- filename
name or path of file
- Name, Value
Name: 'Delimiter', Value: string: the column separator.
Name: 'WriteRowNames', Value: boolean (default value: %f): when %t, writes row names in the file (first column).
Name: 'WriteVariableNames', Value: boolean (default value: %t): when %t, writes variables names in the file (column names).
Description
The writetable function writes a table into a text file, where data are separated by comma. Accepted file formats are .txt, .dat or .csv.
writetable(t) writes table t into the file table.txt saved in TMPDIR.
writetable(t, filename, Name, Value) can be used to specify the column delimiter, to write the row names and the variable names into the file.
Examples
writetbale(t, filename) and writetbale(t, filename, 'WriteVariableNames', %f)
Code = ["AF"; "NA"; "OC"; "AN"; "AS"; "EU"; "SA"]; NameContinent = ["Africa"; "North America"; "Oceania"; "Antarctica"; "Asia"; "Europe"; "South America"]; Area = [30065000; 24256000; 7687000; 13209000; 44579000; 9938000; 17819000]; // in km2 NumberCountry = [54; 23; 14; %nan; 47; 45; 12]; LifeExpectancy = [60; 78; 75; %nan; 72; 75; 74]; // in years t = table(Code, NameContinent, Area, NumberCountry, LifeExpectancy, ... "VariableNames", ["Code", "NameContinent", "Area", "NumberCountry", "LifeExpectancy"]) // Write the table in TXT file writetable(t, fullfile(TMPDIR, "data.txt")) // Read the TXT file with readtable r = readtable(fullfile(TMPDIR, "data.txt")) // Write the table in TXT file writetable(t, fullfile(TMPDIR, "data.txt"), "WriteVariableNames", %f) // Read the TXT file with readtable r = readtable(fullfile(TMPDIR, "data.txt"))
t = readtable(filename, "WriteRowNames", %t)
History
Версия | Описание |
2024.0.0 | Introduction in Scilab. |
Report an issue | ||
<< varfun | Timeseries/Table | writetimeseries >> |