Giter Club home page Giter Club logo

kg-nest's Introduction

CSV to JSON converter

Description

Sample app to convert CSV data to JSON and insert into database.

Setup

Copy .env.sample to .env and add your relevant configuration values.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Endpoints

1. POST /

Converts a CSV string from the request body to JSON.

Example Request:

name.firstName, name.lastName, age, address.line1, address.line2, address.city, address.state, gender\nRohit, Prasad, 35, A-563 Rakshak Society, New Pune Road, Pune, Maharashtra, male

Response:

[
  {
    "name.firstName": "Rohit",
    "name.lastName": "Prasad",
    "age": 35,
    "address.line1": "A-563 Rakshak Society",
    "address.line2": "New Pune Road",
    "address.city": "Pune",
    "address.state": "Maharashtra",
    "gender": "male"
  }
]

2. POST /file

Reads a CSV file from a path specified in the configuration, converts it to JSON, and inserts the data into a database.

Response:

{
  "count": 100000
}

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Assumptions

  1. CSV file is expected to have UTF-8 encoding
  2. First Name and Last Name are mandatory
  3. Separator (,) can not be used in values

License

Nest is MIT licensed.

kg-nest's People

Contributors

vishalbiswas avatar

Watchers

 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.