twelvearrays / Adapter

A simple adapter for elegantly importing CSV files via

Home Page:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool CSV Importer Adapter

Build Status Codecov NPM version Standard Version dependencies Status devDependencies Status

A simple adapter for elegantly importing CSV files via (Typescript, ES6, Browser)

Read the developer docs →


License Key

In order to setup, you need to create or sign in to your account and obtain a license key.

Using NPM

If you don't like external dependencies, or you have a nice build system like Webpack in place. You can install and use Flatfile as an npm package.

npm install flatfile-csv-importer --save

Using CDN

The latest version of the package is available via CDN so you can just drop it into your website and start using it.


Add the following code before the ending </body> tag in your html.

<script src=""></script>


  var importer = new FlatfileImporter('demo-account', {
    fields: [{
      label: 'Robot Name',
      key: 'name'
    }, {
      label: 'Shield Color',
      key: 'shieldColor',
      validator: /^[a-zA-Z]+$/
    }, {
      label: 'Robot Helmet Style',
      key: 'helmetStyle',
    }, {
      label: 'Call Sign',
      key: 'sign',
      alternates: ['nickname', 'wave'],
      validator: /^\w{4}$/
    type: 'Robot'

  importer.requestDataFromUser().then(function(results) {

    // replace this setTimeout with an ajax request to your server with the data
    doSomethingWithYourData( {

   * Use this function to do something with your data like upload it your server
   * @param data An array of objects matching your earlier configuration
   *   [
   *     {
   *       name: 'R2D2',
   *       shieldColor: 'blue',
   *       helmetStyle: 'awesome',
   *       callSign: 'beep'
   *     }
   *     ...
   *   ]
  function doSomethingWithYourData (data) {



ES6 / Babel

import FlatfileImporter from 'flatfile-csv-importer'
import $ from 'jquery'

// configure your flatfile options here
const options = {}

// Obtain your license key from

// initialize the importer
const importer = new FlatfileImporter(FLATFILE_LICENSE_KEY, options)

// setup your handler
const buttonClickHandler = async () => {
  try {
    const response = await importer.requestDataFromUser()
    await uploadYourData(
  } catch(e) {
    // handle a failed upload


const uploadYourData = (data) => {
  // logic here to upload the clean data your server


Promise Overrides

Flatfile includes a basic native compatible Promise shim for IE support. You can override this with your preferred library by using the following global setting:

FlatfileImporter.Promise = Bluebird.Promise
ezoic increase your site revenue


A simple adapter for elegantly importing CSV files via

License:MIT License


Language:TypeScript 89.7%Language:JavaScript 10.3%