Skip to content

Functionality that reads a csv file and adds it to the databas, using node js and prisma

Notifications You must be signed in to change notification settings

ReisSouza/csv-file-reading

Repository files navigation

CSV-FILE-READING

GitHub repo size GitHub language count GitHub forks Bitbucket open issues Bitbucket open pull requests

Functionality that reads a csv file and adds it to the databas, using node js and prisma

Tools used

express typescript postgress https://img.shields.io/badge/Prisma-3982CE?style=for-the-badge&logo=Prisma&logoColor=white

Adjustments improvements

The project is still in development and the next updates will focus on the following tasks:

  • Check if it already exists in the database
  • Method to get the entire listing

💻 Pré-requisitos

Before starting, make sure you've met the following requirements:

  • You have installed the latest version of Node JS

🚀 Installing csv-file-reading

To install csv-file-reading, follow these steps:

Install dependencies :

yarn install 

☕ Using csv-file-reading

First remove the .exmple from the .env.exmple file, then add values for the following environment variables, PORT, DATABASE_URL

Running server:

yarn dev

Create table:

npx prisma migrate dev

To use csv-file-reading, follow these steps:

To use send a post to the route http://localhost:PORT UTILIZED/insertBooks, passing a multipart, named file and a csv file.

obs: the code was structured based on the use example worksheet, for the test to be successful, use the example worksheet, otherwise it will be necessary to adjust the code PORTA UTILIZED

Modifications for use:

  1. First I created your new migration structure, in the csv-file-reading/prisma/schema.prisma file run the command below. Creating the Migrate Prism:
yarn prisma
  1. Set your type in the csv-file-reading/src/types/list.ts

obs:From now on all changes will be made in the same file

  1. In the csv-file-reading/src/routes.ts file, replace the line 31ate to 35, with the structure of your type
  2. If your table didn't have a header that you want to remove, remove line 39, if necessary, skip the header, change const listWithoutHeader = list.slice(N, -1), where N will be the number of lines it will skip
  3. On line 42 change the destructuring as if type
  4. In line 43, if line 39 has been removed, change the listWithoutHeader to list variable and in the line below return the new list values to date

After making these changes, run the server, and process with a usage model

📫 Contributing to csv-file-reading

To contribute csv-file-reading, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<message_commit>'
  4. Push to original branch:!git remote add origin https://:@github.com//reponame.git
  5. Create the pull request.

!git remote add origin https://:@github.com//https://github.com/ReisSouza/csv-file-reading.git

to create your personal access token -

in your GitHub account go to settings go to developer settings go to Personal Access Tokens generate new token make sure you save it as you only see it once

Alternatively, see the GitHub documentation at how to create a pull request.

😄 Be one of the contributors

📝 Licença

MIT

⬆ Back to top

About

Functionality that reads a csv file and adds it to the databas, using node js and prisma

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published