writetable
write a table to file
Syntax
writetable(t) writetable(t, filename) writetable(..., OptionName, Value, ...)
Arguments
- t
table
- filename
name or path of file
- "Delimiter", string
the column separator. Default value: ",".
- "WriteRowNames", boolean
when %t, writes row names in the file (first column). Default value: %f.
- "WriteVariableNames", boolean
when %t, writes variables names in the file (column names). Default value: %t.
Optional pairs OptionName, Value are:
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, OptionName, 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 >> |