-1

I am working on a project where I would like users to be able to upload an excel file through my react frontend. I need the uploaded document's data to be stored in a database so I can access it for different graphs and for an algorithm to change the data amounts. I am using PostgreSQL, React, Django, restful apis, and PostgreSQL. Any info on how to do this would be great. Thanks.

camab
  • 3
  • 3
  • The heavy lifting will have to happen in django: https://stackoverflow.com/questions/38019267/import-data-from-excel-spreadsheet-to-django-model – Mike Organek Jul 07 '20 at 22:27

2 Answers2

0

You will not be able to do that directly in Postgres. The best you can do is store the binary data in a bytea field and then pull it out for viewing/manipulating in some other program e.g. Excel, LibreOffice. Then save in that program and push back to Postgres. You may need to rethink what you want.

Adrian Klaver
  • 15,886
  • 2
  • 17
  • 28
0

I'd recommend you start by arranging your database: thinking about what and how you want to store the data.

Then you'll have to create an endpoint on Django to submit the files:

  1. This endpoint can get the file, read and store its data into a database.

    • This is not the best idea, because you'll have to wait for the whole process to be done.
  2. This endpoint can get the file and store it in a directory.

    • This is better, because then you'll be able to handle it in an asynchronous way. But it's more complicated, because you'll have to use some sort of a scheduler to check the directory once in a while for new files, or you'll have to use a message-broker to create task queues, to deal with the data ingestion.

You'd also have to create some conditions and/or treatments to prevent unwanted results: data structure of the file, extension, size, etc.

Now, on React, you'd have to create a form that, when submitted, make a request to the above endpoint.

These are the first solutions that came into mind.