![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
flatfile-csv-importer
Advanced tools
A simple adapter for elegantly importing CSV files via flatfile.io (Typescript, ES6, Browser)
A simple adapter for elegantly importing CSV files via flatfile.io (Typescript, ES6, Browser)
Read the developer docs → https://developers.flatfile.io/docs/install
License Key
In order to setup, you need to create or sign in to your flatfile.io account and obtain a license key.
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
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
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>
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)
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
FAQs
A simple adapter for elegantly importing CSV files via flatfile.io (Typescript, ES6, Browser)
The npm package flatfile-csv-importer receives a total of 0 weekly downloads. As such, flatfile-csv-importer popularity was classified as not popular.
We found that flatfile-csv-importer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.