# Class CSVParser

java.lang.Object
com.codename1.io.CSVParser

public class CSVParser extends Object

The `CSVParser` allows importing data into applications quickly from a CSV source. CSV is a file format that is supported by all spreadsheets and most databases for data exchange.

The sample below lists a simple hardcoded CSV within the table:

    Form hi = new Form("CSV Parsing", new BorderLayout());
    CSVParser parser = new CSVParser();
    try(Reader r = new com.codename1.io.CharArrayReader("1997,Ford,E350,\"Super, \"\"luxurious\"\" truck\"".toCharArray())) {
        String[][] data = parser.parse(r);
        String[] columnNames = new String[data[0].length];
        for(int iter=  0 ; iter

    @author Shai Almog

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CSVParser()`
  Initializes a parser with the default comma (',') separator char
  `CSVParser(char separatorChar)`
  Allows creating a parser with a custom separator char

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String[][]`
  `parse(InputStream r)`
  Parses input from the given stream and returns the tokens broken into rows and columns
  `String[][]`
  `parse(InputStream r, String encoding)`
  Parses input from the given stream and returns the tokens broken into rows and columns
  `String[][]`
  `parse(java.io.Reader r)`
  Parses input from the given reader and returns the tokens broken into rows and columns

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CSVParser

    public CSVParser()
    Initializes a parser with the default comma (',') separator char

  - ### CSVParser

    public CSVParser(char separatorChar)

    Allows creating a parser with a custom separator char

    ###### Parameters

    - `separatorChar`: custom separator character such as semi-colon (';') etc.

- ## Method Details

  - ### parse

    public String[][] parse(InputStream r) throws java.io.IOException

    Parses input from the given stream and returns the tokens broken into rows and columns

    ###### Parameters

    - `r`: the input stream

    ###### Returns

    array of rows and columns

    Throws:
      `java.io.IOException`

  - ### parse

    public String[][] parse(InputStream r, String encoding) throws java.io.IOException

    Parses input from the given stream and returns the tokens broken into rows and columns

    ###### Parameters

    - `r`: the input stream

    - `encoding`: the encoding of the stream

    ###### Returns

    array of rows and columns

    Throws:
      `java.io.IOException`

  - ### parse

    public String[][] parse(java.io.Reader r) throws java.io.IOException

    Parses input from the given reader and returns the tokens broken into rows and columns

    ###### Parameters

    - `r`: the reader stream

    ###### Returns

    array of rows and columns

    Throws:
      `java.io.IOException`