Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

flatfile-csv-importer

flatfilers6.1kMIT0.2.13TypeScript support: included

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

csv, importer, import, convert, json, parse, parser, csv-parse, parse, async, await, ES6, ES7, typescript

readme

Flatfile.io CSV Importer Adapter

Build Status Codecov NPM version Standard Version dependencies Status devDependencies Status

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

Read the developer docs → https://developers.flatfile.io/docs/install

Preview

License Key

In order to setup, you need to create or sign in to your flatfile.io 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.

https://unpkg.com/flatfile-csv-importer/build/dist/index.min.js

Quickstart

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


<script src="https://unpkg.com/flatfile-csv-importer/build/dist/index.min.js"></script>

<script>
  var LICENSE_KEY = 'PASTE YOUR KEY HERE'

  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) {
    importer.displayLoader()

    // replace this setTimeout with an ajax request to your server with the data
    doSomethingWithYourData(results.data).then(function() {
      robotImporter.displaySuccess()
    })
  })

  /**
   * 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) {

  }

</script>

ES6 / Babel

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

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

// Obtain your license key from https://flatfile.io
const LICENSE_KEY = 'PASTE YOUR KEY HERE'

// 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(response.data)
  } catch(e) {
    // handle a failed upload
  }

}

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

$("#upload-button").click(buttonClickHandler)

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

changelog

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.2.11 (2020-06-17)

Bug Fixes

  • imports: release 0.2.10 (a601586)

0.2.9 (2020-02-04)

0.2.8 (2020-02-04)

0.2.7 (2020-01-29)

0.2.6 (2020-01-20)

0.2.5 (2020-01-17)

0.2.4 (2020-01-07)

0.2.2 (2019-10-24)

0.2.0 (2019-10-24)

Features

  • add custom validator callbacks (6ee8ef9)

0.1.16 (2019-06-09)

0.1.15 (2019-06-09)

0.1.14 (2019-05-19)

0.1.13 (2019-05-19)

0.1.12 (2018-07-11)

0.1.11 (2018-07-11)

0.1.10 (2018-07-11)

0.1.9 (2018-04-24)

0.1.8 (2018-04-24)

0.1.7 (2018-04-24)

0.1.6 (2018-04-24)

0.1.5 (2018-04-24)

0.1.4 (2018-04-24)

0.1.3 (2018-04-24)

0.1.2 (2018-04-24)

0.1.1 (2018-04-24)

0.1.0 (2018-04-24)

0.0.7 (2018-03-27)

0.0.6 (2018-01-03)

0.0.5 (2018-01-03)

0.0.4 (2018-01-03)

0.0.3 (2018-01-03)

0.0.2 (2018-01-03)

1.4.1 (2017-06-27)

1.4.0 (2017-03-02)

Features

  • gh-pages: add package script for publishing docs to gh-pages (1dfe830), closes #14
  • publish: add one-step publish process (7b9b857), closes #15

1.3.0 (2017-03-01)

Bug Fixes

  • hash.js: correctly pre-build hash.js for the browser (1fe0b10)
  • watch: exclude build/*/.spec.js from ava to avoid double execution (e365656)

Features

  • browser: add browser build, tests, and sample sha256 library method (01f67d1)
  • watch: use concurrently for the watch task (7fa64b8), closes #11

1.2.2 (2017-02-17)

Bug Fixes

  • tsconfig: set rootDir option when outDir option is used (3577caa), closes #9

1.2.1 (2017-02-14)

1.2.0 (2017-02-14)

Features

  • github: add sample GitHub issue template, PR template, and contributing guidelines (9c95249)
  • watch: add unified watch task with multiview (973966e)

1.1.1 (2017-02-13)

1.1.0 (2017-02-13)

Features

  • examples: improve browser usage example (c8199e7)
  • starter: add changelogs and examples (5f18048)