Fliplet.CSV

Install

Add the fliplet-csv dependency to your screen or app resources.

Fliplet.CSV.encode()

(Returns String)

Encodes JSON data into CSV.

Fliplet.CSV.encode(data, options);

The CSV JS API uses Papa Parse as the underlying engine. This means it’s capable of generating CSV with different data formats. Examples:

// Specifying a collection of entries
Fliplet.CSV.encode([
  { 'Column 1', 'foo', 'Column 2': 'bar' },
  { 'Column 1', 'abc', 'Column 2': 'def' }
]);

// Pick specific columns from a collection of entries
Fliplet.CSV.encode([
  { 'Column 1', 'foo', 'Column 2': 'bar', 'Column 3': 'baz' },
  { 'Column 1', 'abc', 'Column 2': 'def', 'Column 3': 'ghi' }
], {
  columns: ['Column 3', 'Column 1'] // Show only the specified columns, in given order
});

// Specifying fields and data explicitly
Fliplet.CSV.encode({
  fields: ['Column 1', 'Column 2'],
  data: [
    ['foo', 'bar'],
    ['abc', 'def']
  ]
});

// Two-line, comma-delimited, without header row
Fliplet.CSV.encode([
  ['1-1', '1-2', '1-3'],
  ['2-1', '2-2', '2-3']
]);

Fliplet.CSV.decode()

(Returns Array)

Decodes CSV string into JSON data.

Fliplet.CSV.decode(csv, options);

Fliplet.CSV.download()

(Returns Promise)

Downloads JSON data as a CSV file.

Note Downloading CSV files only works in web apps.

Fliplet.CSV.download(data, options);

Fliplet.CSV.email()

Attachs CSV file to an email.

(Returns Promise)

Emails JSON data as a CSV attachment.

Note Attaching CSV files to emails only works in native apps.

Fliplet.CSV.email(data, options);

Back to API documentation