Csv.Document
Returns the contents of the CSV document as a table.
function (optionalsource
as nullable any, optionalcolumns
as nullable any, optionaldelimiter
as nullable any, optionalextraValues
as nullable any, optionalencoding
as nullable any) as table
Returns the contents of the CSV document as a table.
If a record is specified for <code>columns</code> (and <code>delimiter</code>, <code>extraValues</code>, and <code>encoding</code> are null), the following record fields may be provided:
<ul>
<li> <code>Delimiter</code>: The column delimiter. Default: <code>","</code>.</li>
<li> <code>Columns</code>: Can be null, the number of columns, a list of column names, or a table type. If the number of columns is lower than the number found in the input, the additional columns will be ignored. If the number of columns is higher than the number found in the input, the additional columns will be null. When not specified, the number of columns will be determined by what is found in the input.</li>
<li> <code>Encoding</code>: The text encoding of the file. Default: 65001 (UTF-8).</li>
<li> <code>CsvStyle</code>: Specifies how quotes are handled. <code>CsvStyle.QuoteAfterDelimiter</code> (default): Quotes in a field are only significant immediately following the delimiter. <code>CsvStyle.QuoteAlways</code>: Quotes in a field are always significant, regardless of where they appear.</li>
<li> <code>QuoteStyle</code>: Specifies how quoted line breaks are handled. <code>QuoteStyle.None</code> (default): All line breaks are treated as the end of the current row, even when they occur inside a quoted value. <code>QuoteStyle.Csv</code>: Quoted line breaks are treated as part of the data, not as the end of the current row.</li>
Accessing data
Process CSV text with column headers
Table.PromoteHeaders(Csv.Document("OrderID,Item
1,Fishing rod
2,1 lb. worms"))
Table.FromRecords({ [ OrderID = "1", Item = "Fishing rod" ], [ OrderID = "2", Item = "1 lb. worms" ] })
Last modified 4yr ago