1.4.0 • Published 6 years ago

csvchecker v1.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

csvchecker 1.4

A module that analyzes a given csv file and compare his header with a referencial one in order to allow a user to correct him so it fits an API's requirement.

Contents

+ Install
+ Usage
+ License

Install

npm install csvchecker

Usage

1. Add HTML markup

<div id="wrapper_differences"></div>

2. Import

import { CsvChecker } from './node_modules/csvchecker/dist/csvChecker.js';

3. Instanciate

const csvChecker = new CsvChecker(options);
csvChecker.process(file);
  • file : Must be a csv file with the first row as header (Papaparse used for parsing).
  • options : Object with several options. Details below.

Options

const options = {
    'referencialHeader' : ['firstname','lastname','key_word'],
    'apiPath' : 'pathOfYourAPI',
    'areFieldsRequired' : true, // optional, false by default
    'correspondenceCoefficient' : 0.8, // optional, 0.8 by default
    'subscription' : handler // optional, null by default
}
  • referencialHeader : Array of strings expected by the API (csv header that we want).
  • apiPath : String defining POST route to send lines of the corrected csv.
  • areFieldsRequired : Boolean which defines if all expected fields are required or not.
  • correspondenceCoefficient : Float between 0-1 which defines the correspondence coefficient between expected strings (csv header that we want in referencialHeader) and csv header in the csv given. (0.8 must be a good value)
  • subscription : function which will be called with the server response after the csv is sent to the API.

Example of a subscription function :

// print the server response in the console after the csv is sent
const handler = function(response){
    console.log(response);
}

License

MIT license.

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.5

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago