0.2.4 • Published 13 days ago

@vizzu/csv-parser v0.2.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
13 days ago

Vizzu CSV parser plugin

This plugin enables you to parse CSV files and transform them into Vizzu compatible data. It's designed with features like:

  • Automatic delimiter recognition
  • Header availability check
  • Flexible input parameters

Install

$ npm install @vizzu/csv-parser

Usage

To use the plugin, simply add it to your Vizzu instance as a feature:

import { CSVParser } from '@vizzu/csv-parser'

chart.features(new CSVParser(), true)

You can pass your data in one of two ways. Via plain text:

chart.animate({
  data: {
    csv: {
      content: contentText,
      options: {
        encoding: 'utf8'
      }
    }
  }
})

Via URL:

chart.animate({
  data: {
    csv: {
      url: 'https://yourdomain.com/data.csv',
      options: {
        encoding: 'utf8'
      }
    }
  }
})

The plugin accepts two input parameters as a data source:

NameTypeDescription
contentStringPlain CSV text
urlStringReference to the CSV file

Additionally, it accepts an 'options' parameter with various properties to customize the behavior of the parser:

NameTypeDefault valueDescription
encodingStringutf-8The character encoding of the file.
delimiterString,The delimiter used in the CSV file
hasHeaderBooleanfalseA boolean value specifying whether the file contains a header.
headersArray[]An array of strings providing headers if they are not present in the CSV file.
autoheaderBooleanTrueA boolean value indicating whether to generate headers automatically if they are missing.
emptyColumnPrefixStringColumnA string defining the prefix for any empty columns.

All parameters are optional, with default values applied if not provided.

Extracting information

You can easily extract specific details from the csv by requesting a parameter in the following way.

chart.feature.csvParser.hasHeader
chart.feature.csvParser.delimiter
chart.feature.csvParser.data

Three pieces of data can be extracted: the separator (that was specified or automatically recognized), whether the file contains a header or not, and the parsed data structured for Vizzu.

License

Copyright © 2021-2023 Vizzu Inc.

Released under the Apache 2.0 License.

0.2.4

13 days ago

0.2.3

1 month ago

0.2.1

1 month ago

0.2.2

1 month ago

0.2.0

2 months ago

0.1.3

4 months ago

0.1.0

4 months ago

0.1.2

4 months ago

0.1.1

4 months ago

0.9.1-alpha-1

5 months ago

0.9.0-alpha

5 months ago