{"route":"/en-US-v0.14.1/reference/data-loading/csv/","title":"CSV","description":"Documentation for the `csv` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"parameters","name":"Parameters","children":[{"id":"parameters-source","name":"source","children":[]},{"id":"parameters-delimiter","name":"delimiter","children":[]},{"id":"parameters-row-type","name":"row-type","children":[]}]},{"id":"definitions","name":"Definitions","children":[{"id":"definitions-decode","name":"Decode CSV","children":[{"id":"definitions-decode-data","name":"data","children":[]},{"id":"definitions-decode-delimiter","name":"delimiter","children":[]},{"id":"definitions-decode-row-type","name":"row-type","children":[]}]}]}],"body":{"kind":"func","content":{"path":[],"name":"csv","title":"CSV","keywords":[],"oneliner":"Reads structured data from a CSV file.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Reads structured data from a CSV file.</p>\n<p>The CSV file will be read and parsed into a 2-dimensional array of strings:\nEach row in the CSV file will be represented as an array of strings, and all\nrows will be collected into a single array. Header rows will not be\nstripped.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> results <span class=\"typ-op\">=</span> <span class=\"typ-func\">csv</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;example.csv&quot;</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-func\">#</span><span class=\"typ-func\">table</span><span class=\"typ-punct\">(</span>\n  columns<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">[</span><span class=\"typ-strong\">*Condition*</span><span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span> <span class=\"typ-punct\">[</span><span class=\"typ-strong\">*Result*</span><span class=\"typ-punct\">]</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-op\">..</span>results<span class=\"typ-punct\">.</span><span class=\"typ-func\">flatten</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/c192b88f7dd7e11a0cbe1419b109e999.png\" alt=\"Preview\"></div></div>"}],"self":false,"params":[{"name":"source","details":[{"kind":"html","content":"<p>A <a href=\"/en-US-v0.14.1/reference/syntax/#paths\">path</a> to a CSV file or raw CSV bytes.</p>"}],"types":["str","bytes"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"delimiter","details":[{"kind":"html","content":"<p>The delimiter that separates columns in the CSV file.\nMust be a single ASCII character.</p>"}],"types":["str"],"strings":[],"default":"<code><span class=\"typ-str\">&quot;,&quot;</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"row-type","details":[{"kind":"html","content":"<p>How to represent the file's rows.</p>\n<ul>\n<li>If set to <code>array</code>, each row is represented as a plain array of\nstrings.</li>\n<li>If set to <code>dictionary</code>, each row is represented as a dictionary\nmapping from header keys to strings. This option only makes sense when\na header row is present in the CSV file.</li>\n</ul>"}],"types":["type"],"strings":[],"default":"<code>array</code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[{"path":["csv"],"name":"decode","title":"Decode CSV","keywords":[],"oneliner":"Reads structured data from a CSV string/bytes.","element":false,"contextual":false,"deprecationMessage":"`csv.decode` is deprecated, directly pass bytes to `csv` instead","deprecationUntil":"0.15.0","details":[{"kind":"html","content":"<p>Reads structured data from a CSV string/bytes.</p>"}],"self":false,"params":[{"name":"data","details":[{"kind":"html","content":"<p>CSV data.</p>"}],"types":["str","bytes"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false},{"name":"delimiter","details":[{"kind":"html","content":"<p>The delimiter that separates columns in the CSV file.\nMust be a single ASCII character.</p>"}],"types":["str"],"strings":[],"default":"<code><span class=\"typ-str\">&quot;,&quot;</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false},{"name":"row-type","details":[{"kind":"html","content":"<p>How to represent the file's rows.</p>\n<ul>\n<li>If set to <code>array</code>, each row is represented as a plain array of\nstrings.</li>\n<li>If set to <code>dictionary</code>, each row is represented as a dictionary\nmapping from header keys to strings. This option only makes sense\nwhen a header row is present in the CSV file.</li>\n</ul>"}],"types":["type"],"strings":[],"default":"<code>array</code>","positional":false,"named":true,"required":false,"variadic":false,"settable":false}],"returns":["array"],"scope":[]}]}}}