Git Product home page Git Product logo

csvtomarkdowntable's Introduction

CSV To Markdown Table

npm version npm Coverage Status GitHub license

Simple JavaScript CSV to Markdown Table Converter

You can see it in action and play with the Live Example.

Requires no external libraries. Works in Node as well as in the browser.

Install

npm install csv-to-markdown-table

Usage

CLI

This package also includes a CLI tool. You can install it globally with:

npm install -g csv-to-markdown-table

Then you can use it like so:

$ csv-to-markdown-table --help
Usage: csv-to-markdown-table [options]
// … help output

$ csv-to-markdown-table --delimiter ',' --headers < example.csv
| cats | dogs | fish | 
|------|------|------| 
| 1    | 2    | 3    | 
| 4    | 5    | 6    |
$ csv-to-markdown-table
Reading from stdin... (press Ctrl+D at the start of a line to finish)
CSV Delimiter: \t (tab) Headers: false
[interactive input]

Raw JS via Global

console.log(
  csvToMarkdown( "header1,header2,header3\nValue1,Value2,Value3", ",", true)
);

Node / npm

const csvToMarkdown = require("csv-to-markdown-table");

console.log(
	csvToMarkdown("header1,header2,header3\nValue1,Value2,Value3", ",", true)
);

TypeScript

import csvToMarkdown from "csv-to-markdown-table";

console.log(
  csvToMarkdown("header1,header2,header3\nValue1,Value2,Value3", ",", true)
);

Outputs:

| header1 | header2 | header3 | 
|---------|---------|---------| 
| Value1  | Value2  | Value3  | 

Which displays in markdown as:

header1 header2 header3
Value1 Value2 Value3

csvtomarkdowntable's People

Contributors

donatj avatar dependabot[bot] avatar dependabot-preview[bot] avatar curtisgibby avatar terriann avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.