CSVParser - Scoped
-
- UpdatedJan 30, 2025
- 2 minutes to read
- Yokohama
- API reference
The CSVParser API provides methods for parsing comma-separated value (CSV) formatted records into an object or an array.
This API runs in the sn_impex
namespace.
CSVParser - parseLineToArray(String cvsLine, String delimiter, String quoteCharacter)
Parses passed in CSV formatted content into an array.
Name | Type | Description |
---|---|---|
csvLine | String | CSV content to parse. |
delimiter | String | Optional. Character used to delineate the fields in the source CSV
content. Default: Comma ',' |
quoteCharacter | String | Optional. Character used as the quote character in the source CSV content.
Default: Double quote '"' |
Type | Description |
---|---|
Array | Array containing the parsed values for each element in the passed-in CSV
content. For example: |
Example
This example shows simple CSV formatted content parsed into a returned array.
Output:
CSVParser - parseLineToObject(String cvsLine, Array headers, String delimiter, String quoteCharacter)
Parses passed in CSV formatted content into an object.
Type | Description |
---|---|
Object | Object containing the header and corresponding value for each element in the
passed-in CSV content. For example: |
Example
This example shows CSV formatted content parsed into a returned object.
Output:
Example
This example shows an exception response because of an invalid pass of the header parameter.
Output: