@robinpath/csv
0.1.2Node.jsPublicParse and stringify CSV data
CSV
Parse and stringify CSV data
Package: @robinpath/csv | Category: Utility | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the csv module when you need to:
- Parse a CSV string into an array of objects (first row = headers) -- Use
csv.parseto perform this operation - Convert an array of objects into a CSV string -- Use
csv.stringifyto perform this operation - Extract header names from a CSV string -- Use
csv.headersto perform this operation - Extract all values from a specific column -- Use
csv.columnto perform this operation - Parse a CSV string into an array of arrays (raw, no header mapping) -- Use
csv.rowsto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
parse | Parse a CSV string into an array of objects (first row = headers) | Array of objects where keys are header names |
stringify | Convert an array of objects into a CSV string | CSV formatted string |
headers | Extract header names from a CSV string | Array of header name strings |
column | Extract all values from a specific column | Array of values from the specified column |
rows | Parse a CSV string into an array of arrays (raw, no header mapping) | Array of arrays (each inner array is a row of strings) |
Functions
parse
Parse a CSV string into an array of objects (first row = headers)
Module: csv | Returns: array -- Array of objects where keys are header names
csv.parse "name,age\nAlice,30\nBob,25"
| Parameter | Type | Required | Description |
|---|---|---|---|
csvString | string | Yes | The CSV string to parse |
delimiter | string | No | Column delimiter (default: comma) |
stringify
Convert an array of objects into a CSV string
Module: csv | Returns: string -- CSV formatted string
csv.stringify $data
| Parameter | Type | Required | Description |
|---|---|---|---|
data | array | Yes | Array of objects to convert |
delimiter | string | No | Column delimiter (default: comma) |
headers
Extract header names from a CSV string
Module: csv | Returns: array -- Array of header name strings
csv.headers "name,age\nAlice,30"
| Parameter | Type | Required | Description |
|---|---|---|---|
csvString | string | Yes | The CSV string |
column
Extract all values from a specific column
Module: csv | Returns: array -- Array of values from the specified column
csv.column "name,age\nAlice,30" "name"
| Parameter | Type | Required | Description |
|---|---|---|---|
csvString | string | Yes | The CSV string |
columnName | string | Yes | Name of the column to extract |
rows
Parse a CSV string into an array of arrays (raw, no header mapping)
Module: csv | Returns: array -- Array of arrays (each inner array is a row of strings)
csv.rows "name,age\nAlice,30"
| Parameter | Type | Required | Description |
|---|---|---|---|
csvString | string | Yes | The CSV string to parse |
delimiter | string | No | Column delimiter (default: comma) |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "Parse and validate result"
do
set $result as csv.parse "name,age\nAlice,30\nBob,25"
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. Multi-step CSV workflow
Chain multiple csv operations together.
@desc "Parse, stringify, and more"
do
set $r_parse as csv.parse "name,age\nAlice,30\nBob,25"
set $r_stringify as csv.stringify $data
set $r_headers as csv.headers "name,age\nAlice,30"
print "All operations complete"
enddo
2. Safe parse with validation
Check results before proceeding.
@desc "Parse and validate result"
do
set $result as csv.parse "name,age\nAlice,30\nBob,25"
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.2 | latest | 1 months ago |
Related Modules
@robinpathv0.1.4
SMTP email sending and address parsing for RobinPath
hash
JS@robinpathv0.1.3
Cryptographic hashing utilities: MD5, SHA family, HMAC, CRC32, file hashing, UUID v5 generation, secure random bytes, and content fingerprinting
apollo
JS@robinpathv0.1.2
Apollo module for RobinPath.
archive
JS@robinpathv0.1.5
Create and extract .zip and .tar.gz file archives
$ robinpath add @robinpath/csv
