|
| 1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
| 2 | +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 3 | + |
| 4 | +<html xmlns = "http://www.w3.org/1999/xhtml"> |
| 5 | +<!-- |
| 6 | +SAME AS NELSON SOFTWARE |
| 7 | +--> |
| 8 | + |
| 9 | +<head> |
| 10 | +<meta name="generator" content= |
| 11 | +"HTML Generated by Nelson"/> |
| 12 | +<link rel="stylesheet" type="text/css" href="style.css" /> |
| 13 | +<link rel="stylesheet" href="mono-blue.css" type="text/css" /> |
| 14 | +<script src = "highlight.pack.js" type = "text/javascript"> |
| 15 | +</script> |
| 16 | +<script type = "text/javascript">hljs.highlightAll();</script> |
| 17 | +</script> |
| 18 | + <meta http-equiv="Content-Type" content = "text/html; charset=utf-8" /> |
| 19 | + <title>Read/Write table to files</title> |
| 20 | + |
| 21 | +</head> |
| 22 | +<body> |
| 23 | + |
| 24 | +<div class = "manualnavbar"> |
| 25 | +<table width = "100%"><tr> |
| 26 | + |
| 27 | +<td width="30%" class="previous"> |
| 28 | +<span class="top"><a href="2_direct_compution_with_table.html"><< Direct computation with Table</a></span> |
| 29 | +</td> |
| 30 | + |
| 31 | +<td width="40%" class="center"> |
| 32 | +<span class="top"><a href="chapter_table.html">Tables</a></span> |
| 33 | +</td> |
| 34 | + |
| 35 | +<td width = "30%" class = "next"> |
| 36 | +<span class = "next"><a href = "array2table.html">array2table >></a></span> |
| 37 | +</td> |
| 38 | + |
| 39 | +</tr></table> |
| 40 | +<hr /> |
| 41 | + |
| 42 | +<h1 class="refname">Read/Write table to files</h1> |
| 43 | +<hr/> |
| 44 | + |
| 45 | +<h3>Description</h3> |
| 46 | +<hr/> |
| 47 | + |
| 48 | +<p></p> |
| 49 | + |
| 50 | + <p>Nelson provides extensive capabilities for reading and writing tables to files, supporting both text-based and binary storage formats to meet different data management needs.</p> |
| 51 | + <p>Text files (.csv, .txt, etc.):</p> |
| 52 | + <ul> |
| 53 | + <li>writetable() exports tables to delimited text files with customizable separators</li> |
| 54 | + <li>readtable() imports tables from delimited text files with automatic format detection</li> |
| 55 | + <li>Text files preserve variable names and data in human-readable format</li> |
| 56 | + </ul> |
| 57 | + <p>Binary file:</p> |
| 58 | + <ul> |
| 59 | + <li>Nelson HDF5 format (.nh5): |
| 60 | + <ul><li>Efficient binary storage using HDF5 format</li><li>Preserves all table metadata and data types</li><li>Use save -nh5 and load commands</li></ul> |
| 61 | + </li> |
| 62 | + </ul> |
| 63 | + <p>Binary format is recommended for preserving exact numeric precision and working with large datasets.</p> |
| 64 | + |
| 65 | + |
| 66 | +<h3>Examples</h3> |
| 67 | +<hr/> |
| 68 | + |
| 69 | +<p>Read/Write table to .nh5 file</p> |
| 70 | +<pre> |
| 71 | +<code class = "nelson">% Create a sample table with sensor data |
| 72 | +T = table([1.5; -2.3; 4.7], [0.5; 1.1; -0.7], [-1; 2; 3], 'VariableNames', {'Voltage', 'Current', 'Resistance'}); |
| 73 | +R = T; |
| 74 | +filename = [tempdir(), 'table_example.nh5']; |
| 75 | +save(filename, '-nh5', 'T'); |
| 76 | +clear T |
| 77 | +load(filename, 'T'); |
| 78 | +assert(isequal(T, R)); |
| 79 | +T |
| 80 | +</code> |
| 81 | +</pre> |
| 82 | +<p>Read/Write table to text file</p> |
| 83 | +<pre> |
| 84 | +<code class = "nelson">% Create a sample table with sensor data |
| 85 | +T = table([1.5; -2.3; 4.7], [0.5; 1.1; -0.7], [-1; 2; 3], 'VariableNames', {'Voltage', 'Current', 'Resistance'}); |
| 86 | +filename = [tempdir(), 'table_example.csv']; |
| 87 | +writetable(T, filename); |
| 88 | +T2 = readtable(filename); |
| 89 | +</code> |
| 90 | +</pre> |
| 91 | + |
| 92 | +<h3>See also</h3> |
| 93 | +<hr/> |
| 94 | + |
| 95 | +<p> |
| 96 | +<a href = "writetable.html" class = "link">writetable</a>, <a href = "readtable.html" class = "link">readtable</a>, <a href = "load.html" class = "link">load</a>, <a href = "save.html" class = "link">save</a>.</p> |
| 97 | + |
| 98 | +<h3>History</h3> |
| 99 | +<hr/> |
| 100 | + |
| 101 | +<table summary = "history" style="width:50%"> |
| 102 | +<tr> |
| 103 | + <th>Version</th> |
| 104 | + <th>Description</th> |
| 105 | +</tr> |
| 106 | +<tr> |
| 107 | + <td>1.10.0</td> |
| 108 | + <td>initial version</td> |
| 109 | +</tr> |
| 110 | + |
| 111 | +</table> |
| 112 | + |
| 113 | +<h3>Author</h3> |
| 114 | +<hr/> |
| 115 | + |
| 116 | +<p>Allan CORNET</p> |
| 117 | + |
| 118 | +<div class = "manualnavbar"> |
| 119 | +<table width = "100%"><tr> |
| 120 | + |
| 121 | +<td width="30%" class="previous"> |
| 122 | +<span class="top"><a href="2_direct_compution_with_table.html"><< Direct computation with Table</a></span> |
| 123 | +</td> |
| 124 | + |
| 125 | +<td width="40%" class="center"> |
| 126 | +<span class="top"><a href="chapter_table.html">Tables</a></span> |
| 127 | +</td> |
| 128 | + |
| 129 | +<td width = "30%" class = "next"> |
| 130 | +<span class = "next"><a href = "array2table.html">array2table >></a></span> |
| 131 | +</td> |
| 132 | + |
| 133 | +</tr></table> |
| 134 | +<hr /> |
| 135 | + |
| 136 | +</body> |
| 137 | + |
| 138 | +</html> |
| 139 | + |
0 commit comments