All Projects → nzambello → React Csv Reader

nzambello / React Csv Reader

Licence: mit
React component that handles csv file input and its parsing

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to React Csv Reader

React Papaparse
react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
Stars: ✭ 116 (-15.94%)
Mutual labels:  csv, csv-parser, input
Csv
A modern, fast, RFC 4180 compliant parser for JS
Stars: ✭ 38 (-72.46%)
Mutual labels:  csv, parse
Dataclass Csv
Map CSV to Data Classes
Stars: ✭ 133 (-3.62%)
Mutual labels:  csv, csv-parser
Csv
Fast C# CSV parser
Stars: ✭ 53 (-61.59%)
Mutual labels:  csv, csv-parser
Node Csvtojson
Blazing fast and Comprehensive CSV Parser for Node.JS / Browser / Command Line.
Stars: ✭ 1,760 (+1175.36%)
Mutual labels:  csv, parse
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 (+564.49%)
Mutual labels:  csv, csv-parser
Faster Than Csv
Faster CSV on Python 3
Stars: ✭ 52 (-62.32%)
Mutual labels:  csv, csv-parser
Csv Parser
A modern C++ library for reading, writing, and analyzing CSV (and similar) files.
Stars: ✭ 359 (+160.14%)
Mutual labels:  csv, csv-parser
Ngx Papaparse
Papa Parse wrapper for Angular
Stars: ✭ 83 (-39.86%)
Mutual labels:  csv, csv-parser
Etl.net
Mass processing data with a complete ETL for .net developers
Stars: ✭ 129 (-6.52%)
Mutual labels:  csv, csv-parser
Csv Parser
Fast, header-only, extensively tested, C++11 CSV parser
Stars: ✭ 90 (-34.78%)
Mutual labels:  csv, csv-parser
Csvutil
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.
Stars: ✭ 501 (+263.04%)
Mutual labels:  csv, csv-parser
Vroom
Fast reading of delimited files
Stars: ✭ 462 (+234.78%)
Mutual labels:  csv, csv-parser
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 (+542.75%)
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 (+189.86%)
Mutual labels:  csv, csv-parser
Fast Csv
CSV parser and formatter for node
Stars: ✭ 1,054 (+663.77%)
Mutual labels:  csv, csv-parser
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 (-82.61%)
Mutual labels:  csv, csv-parser
Awesomecsv
🕶️A curated list of awesome tools for dealing with CSV.
Stars: ✭ 305 (+121.01%)
Mutual labels:  csv, csv-parser
Csv File Validator
🔧🔦 Validation of CSV file against user defined schema (returns back object with data and invalid messages)
Stars: ✭ 60 (-56.52%)
Mutual labels:  csv, csv-parser
Csv Stream
📃 Streaming CSV Parser for Node. Small and made entirely out of streams.
Stars: ✭ 98 (-28.99%)
Mutual labels:  csv, csv-parser

react-csv-reader

npm version npm Node.js CI a11y axe TypeScript Support

React component that handles csv file input. It handles file input and returns its content as a matrix.

Docs: nzambello.github.io/react-csv-reader

You can try it out in the playground in the docs or in the demo on Codesandbox.

Installation

Install the package with either yarn or npm.

With yarn:

yarn add react-csv-reader

With npm:

npm install --save react-csv-reader

Usage

Basic usage:

import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import CSVReader from 'react-csv-reader'

class App extends Component {
  ...

  render() {
    return (
      <CSVReader onFileLoaded={(data, fileInfo) => console.dir(data, fileInfo)} />
    )
  }
}

ReactDOM.render(<App />, document.getElementById('root'))

More complex example:

import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import CSVReader from 'react-csv-reader'

class App extends Component {
  ...

  const papaparseOptions = {
    header: true,
    dynamicTyping: true,
    skipEmptyLines: true,
    transformHeader: header =>
      header
        .toLowerCase()
        .replace(/\W/g, '_')
  }

  render() {
    return (
      <CSVReader
        cssClass="csv-reader-input"
        label="Select CSV with secret Death Star statistics"
        onFileLoaded={this.handleForce}
        onError={this.handleDarkSideForce}
        parserOptions={papaparseOptions}
        inputId="ObiWan"
        inputName="ObiWan"
        inputStyle={{color: 'red'}}
      />
    )
  }
}

ReactDOM.render(<App />, document.getElementById('root'))

Parameters

Name Type Default Description
accept string .csv, text/csv File type accepted by file input.
cssClass string csv-reader-input A CSS class to be applied to the wrapper element.
cssInputClass string csv-input A CSS class to be applied to the <input> element.
cssLabelClass string csv-label A CSS class to be applied to the <label> element.
label string, element If present, it will be rendered in a <label> to describe input aim.
onFileLoaded function (required) The function to be called passing loaded results, see below.
onError function Error handling function.
parserOptions object {} PapaParse configuration object override
inputId string react-csv-reader-input An id to be applied to the <input> element.
inputName string react-csv-reader-input A name attribute to be applied to the <input> element.
inputStyle object {} Some style to be applied to the <input> element.
fileEncoding string UTF-8 Encoding type of the input file.
disabled boolean false Set input disabled attribute.
strict boolean false Throws error on onError if file type is different from accept.

onFileLoaded

When the file has been loaded, it will be parsed with PapaParse from a CSV formatted text to a matrix of strings or a list of objects (using header option). That parsed data is returned to the parent component with onFileLoaded function (it will be passed as an argument). The second argument to onFileLoaded will be an object with infos about loaded file.

// data: PapaParse.ParseResult.data
// fileInfo: IFileInfo
onFileLoaded: (data: Array<any>, fileInfo: IFileInfo) => any

For type definitions, see here.

Testing

This packages uses jest for unit tests and snapshot testing.

To run the tests:

yarn test

Automated accessibility tests are run with jest-axe.

Contributions

Please follow our convention on commits format.

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].