The CSV text to parse
Optional hasHeaders: booleanCurrently ignored; the first row is always returned as data
Optional delimiter: stringField delimiter; only the first character is used (default: ",")
Optional quote: stringQuote character; only the first character is used (default: '"')
Optional disableNumberConversion: booleanWhen true, every value is returned as a string (default: false)
2D array of rows and columns, or null if the CSV could not be parsed
var rows = parseCsv("Size,Price\nA4,1.50\nA3,2.75", true, ",", "\"", false);
if (rows) {
// skip the header row
for (var i = 1; i < rows.length; i++) {
if (rows[i][0] === Item.getAttributeValue("Size")) {
return rows[i][1] * Item.Quantity;
}
}
}
// Semicolon-separated values, keeping codes such as "007" as strings
var codes = parseCsv("Code;Name\n007;Gold", true, ";", "\"", true);
Generated using TypeDoc
Parse a CSV string into a 2D array of rows and columns. Every row is returned, including the first one, so a header row appears as row 0. Numeric values are converted to numbers unless
disableNumberConversionis true. Returns null when the text cannot be parsed.Use this for CSV text the script already holds (for example from an attribute value or a file's content). To read a CSV file from Global Data, use getGlobalFileCsvContent instead.