Skip to content

Vue.js component to select a CSV file, map the columns to fields, and post it somewhere.

License

Notifications You must be signed in to change notification settings

christianrr/vue-csv-import

 
 

Repository files navigation

Vue.js component to handle CSV uploads with field mapping.

Latest Version on NPM Software License CircleCI

Demo

Demo

Go to the "docs" folder for a working example.

Installation

You can install the package via yarn:

yarn add vue-csv-import

or npm:

npm install vue-csv-import --save

Usage

Import component:

import { VueCsvImport } from '../src';

new Vue({
    components: { VueCsvImport },

    el: '#app',
});

Include in template:

<vue-csv-import url="/url/to/post" :map-fields="['array', 'of', 'field', 'names']"></vue-csv-import>

or with labels:

<vue-csv-import url="/url/to/post" :map-fields="[field1: 'Label 1', field2: 'Label 2']"></vue-csv-import>

or with v-model:

<vue-csv-import v-model="parseCsv" :map-fields="[field1: 'Label 1', field2: 'Label 2']"></vue-csv-import>

Options:

Option Default Description
mapFields N/A (required) These are the field names that the CSV will be mapped to
url null If present, the component will post the mapped values to this url. Otherwise, the component will only emit the value to be used as a normal input
callback null The callback to be called on successful upload. (url required)
catch null The function to be called on an error in posting (url required)
finally null The function to be called no matter what on posting (url required)
tableClass "table" The class to be added to table element
checkboxClass "form-check-input" The class to be added to the checkbox
buttonClass "btn btn-default" The class to be added to buttons
inputClass "form-control-file" The class to be added to the file input
submitBtnText "Submit" The value of the final submit button
loadBtnText "Submit" The value of the initial load file button

Testing

yarn test

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please contact John Gile.

License

The MIT License (MIT). Please see License File for more information.

Credits

About

Vue.js component to select a CSV file, map the columns to fields, and post it somewhere.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Vue 72.7%
  • JavaScript 15.1%
  • HTML 8.1%
  • HCL 4.1%