All Projects → shystruk → Csv File Validator

shystruk / Csv File Validator

Licence: mit
🔧🔦 Validation of CSV file against user defined schema (returns back object with data and invalid messages)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Csv File Validator

Clevercsv
CleverCSV is a Python package for handling messy CSV files. It provides a drop-in replacement for the builtin CSV module with improved dialect detection, and comes with a handy command line application for working with CSV files.
Stars: ✭ 887 (+1378.33%)
Mutual labels:  csv, csv-files, csv-parser
Awesomecsv
🕶️A curated list of awesome tools for dealing with CSV.
Stars: ✭ 305 (+408.33%)
Mutual labels:  csv, csv-files, csv-parser
Filehelpers
The FileHelpers are a free and easy to use .NET library to read/write data from fixed length or delimited records in files, strings or streams
Stars: ✭ 917 (+1428.33%)
Mutual labels:  csv, csv-files, csv-parser
Intellij Csv Validator
CSV validator, highlighter and formatter plugin for JetBrains Intellij IDEA, PyCharm, WebStorm, ...
Stars: ✭ 198 (+230%)
Mutual labels:  csv, csv-files, csv-parser
flatpack
CSV/Tab Delimited and Fixed Length Parser and Writer
Stars: ✭ 55 (-8.33%)
Mutual labels:  csv, csv-parser
Csv
Fast C# CSV parser
Stars: ✭ 53 (-11.67%)
Mutual labels:  csv, csv-parser
Flatfiles
Reads and writes CSV, fixed-length and other flat file formats with a focus on schema definition, configuration and speed.
Stars: ✭ 275 (+358.33%)
Mutual labels:  csv, csv-files
Csv Parser
A modern C++ library for reading, writing, and analyzing CSV (and similar) files.
Stars: ✭ 359 (+498.33%)
Mutual labels:  csv, csv-parser
Jsoncons
A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
Stars: ✭ 400 (+566.67%)
Mutual labels:  csv, csv-parser
Vroom
Fast reading of delimited files
Stars: ✭ 462 (+670%)
Mutual labels:  csv, csv-parser
Fast Csv
CSV parser and formatter for node
Stars: ✭ 1,054 (+1656.67%)
Mutual labels:  csv, csv-parser
csv2latex
🔧 Simple script in python to convert CSV files to LaTeX table
Stars: ✭ 54 (-10%)
Mutual labels:  csv, csv-files
node-emails-from-csv
A simple NodeJS aplication that helps sending emails for events. Uses CSV files for target users.
Stars: ✭ 18 (-70%)
Mutual labels:  csv, csv-files
VBA-CSV-interface
The most powerful and comprehensive CSV/TSV/DSV data management library for VBA, providing parsing/writing capabilities compliant with RFC-4180 specifications and a complete set of tools for manipulating records and fields.
Stars: ✭ 24 (-60%)
Mutual labels:  csv, csv-parser
CsvTextFieldParser
A simple CSV parser based on Microsoft.VisualBasic.FileIO.TextFieldParser.
Stars: ✭ 40 (-33.33%)
Mutual labels:  csv, csv-parser
csvtogs
Take a CSV file and create a Google Spreadsheet with the contents
Stars: ✭ 15 (-75%)
Mutual labels:  csv, csv-parser
Csvquery
A handy SQL runner to work with CSV files
Stars: ✭ 32 (-46.67%)
Mutual labels:  csv, csv-files
comma splice
Fixes CSVs with unquoted commas in values
Stars: ✭ 67 (+11.67%)
Mutual labels:  csv-files, csv-parser
csvlixir
A CSV reading/writing application for Elixir.
Stars: ✭ 32 (-46.67%)
Mutual labels:  csv, csv-parser
Csvutil
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.
Stars: ✭ 501 (+735%)
Mutual labels:  csv, csv-parser

CSV File Validator Twitter URL

MIT Licence codecov Build Status Known Vulnerabilities npm version

Validation of CSV file against user defined schema (returns back object with data and invalid messages)

Getting csv-file-validator

npm

npm install --save csv-file-validator

yarn

yarn add csv-file-validator --save

Example

import CSVFileValidator from 'csv-file-validator'

CSVFileValidator(file, config)
    .then(csvData => {
        csvData.data // Array of objects from file
        csvData.inValidMessages // Array of error messages
    })
    .catch(err => {})

Please see Demo for more details /demo/index.html

API

CSVFileValidator(file, config)

returns the Promise

file

Type: File

.csv file

config

Type: Object

Config object should contain:
headers - Type: Array, row header (title) objects
isHeaderNameOptional - Type: Boolean, skip the header name if it is empty

const config = {
    headers: [], // required
    isHeaderNameOptional: false // default (optional)
}

name

Type: String
name of the row header (title)

inputName

Type: String
key name which will be return with value in a column

optional

Type: Boolean

Makes column optional. If true column value will be return

headerError

Type: Function

If a header name is omitted or is not the same as in config name headerError function will be called with arguments headerName

required

Type: Boolean

If required is true than a column value will be checked if it is not empty

requiredError

Type: Function

If value is empty requiredError function will be called with arguments headerName, rowNumber, columnNumber

unique

Type: Boolean

If it is true all header (title) column values will be checked for uniqueness

uniqueError

Type: Function

If one of the header value is not unique uniqueError function will be called with argument headerName

validate

Type: Function

Validate column value. As an argument column value will be passed For e.g.

function(email) {
    return isEmailValid(email)
}

validateError

Type: Function

If validate returns false validateError function will be called with arguments headerName, rowNumber, columnNumber

isArray

Type: Boolean

If column contains list of values separated by comma in return object it will be as an array

Config example

const config = {
    headers: [
        {
            name: 'First Name',
            inputName: 'firstName',
            required: true,
            requiredError: function (headerName, rowNumber, columnNumber) {
                return `${headerName} is required in the ${rowNumber} row / ${columnNumber} column`
            }
        },
        {
            name: 'Last Name',
            inputName: 'lastName',
            required: false
        },
        {
            name: 'Email',
            inputName: 'email',
            unique: true,
            uniqueError: function (headerName) {
                return `${headerName} is not unique`
            },
            validate: function(email) {
                return isEmailValid(email)
            },
            validateError: function (headerName, rowNumber, columnNumber) {
                return `${headerName} is not valid in the ${rowNumber} row / ${columnNumber} column`
            }
        },
        {
            name: 'Roles',
            inputName: 'roles',
            isArray: true
        },
        {
            name: 'Country',
            inputName: 'country',
            optional: true
        }
    ]
}

Contributing

Any contributions you make are greatly appreciated.

Please read the Contributions Guidelines before submitting a PR.

License

MIT © Vasyl Stokolosa

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].