# 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(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`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## 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 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:
      `IOException`

  - ### parse

    public String[][] parse(InputStream r, String encoding) throws 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:
      `IOException`

  - ### parse

    public String[][] parse(Reader r) throws 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:
      `IOException`