@leafgard/csv2html

Easy and fast Node.JS package / cli for CSV to HTML conversion

Usage no npm install needed!

<script type="module">
  import leafgardCsv2html from 'https://cdn.skypack.dev/@leafgard/csv2html';
</script>

README

csv2html

csv2html

Easy and fast Node.JS package / cli for CSV to HTML conversion

FeaturesInstallationUsageLicense

Features

  • Converts CSV to HTML as Node.JS package or CLI
  • Ability to choose the delimiter
  • Ability to add title to HTML document
  • Converts CSV to HTML fast (± 1s / 200000 lines) - Average on Macbook Pro 2018 w/ i7

Installation

# CLI
$ npm i -g @leafgard/csv2html
OR
$ yarn global add @leafgard/csv2html

# Package
$ npm i @leafgard/csv2html
OR
$ yarn add @leafgard/csv2html

Usage

CLI

Here is a basic CLI usage example:

$ csv2html -i input.csv -o output.html

You can provide options like:

  • -d CSV parsing delimiter, f.e: -d ';'
  • -t Provides title to HTML document: -t 'My document'

Package

Here is a basic usage example as a Node.JS package:

const { CSVToHTML } = require('@leafgard/csv2html')
const converter = new CSVToHTML()

converter
  .setOptions({
    delimiter: ';',
    documentTitle: 'My document'
  }) // (Optional)

  .setInputFile('data.csv')
  .setOutputFile('output.html')

  // You can also turn this into async/await expression
  .convert()
  .then(() => {
    // Do something
  }).catch((err) => {
    // Catch error
  })

License

This project is licensed under the MIT License - see the LICENSE.md file for details.