CSVParser - Verge3D User Manual - Soft8Soft
Description: Learn how to use CSVParser in your interactive 3D apps made with Verge3D

# CSVParser

A parser for CSV (comma-separated value) data. This format is extensively used to retrieve data for further 3D visualization in e-commerce, data analytics, and data science.

## Code Example

`fetch('mydata.csv').then(response => { if (!response.ok) { throw new Error(response.status); } return response.text(); }).then(data => { const rows = v3d.CSVParser.parse(data); rows.forEach(row => { console.log(row); }); }).catch(error => { console.error(`Error fetching CSV data: ${error}`); });`

## Methods

### # .parse(s : String, dialect : Object) → Array

- s — input data in textual form.
- dialect — (optional) CSV dialect object.

`dialect` is a JavaScript object with the following structure:

`const dialect = { delimiter: ",", // columns delimeter character doublequote: true, // allow double quotes lineterminator: "\n", // line terminator character quotechar: '"', // quotation character skipinitialspace: true, // skip initial space in input string skipinitialrows: 0 // skip initial row (e.g. used to represet column labels) };`

Parse CSV string and return an array of rows. Each row is also an array which represents columns of the input data.

## Puzzles

Check out the read CSV puzzle to parse CSV data in a visual way.

## Source

For more info on how to obtain the source code of this module see this page.