team4909 / 2018-Core

2018 Scouting Platform
MIT License
10 stars 3 forks source link

CSV Upload #38

Closed roshanr10 closed 6 years ago

roshanr10 commented 6 years ago

Teams 449 and 2791 would like to contribute data to TGA, but currently use Excel. I would like to integrate a CSV uploader to allow this. Just parse and import each doc to the CouchDB database.

I'm sure some other teams would like something like this to work with their existing workflows.

shashjar commented 6 years ago
  1. Use npm to install couchimport from a prompt
  2. Call on the target database using curl to create the db locally (install curl first if on Windows)
  3. Download the Excel file(s)
  4. Then cat the data files to the database (specify the name of the db and name the file accurately so we don't get everything mixed up)

https://medium.com/ibm-watson-data-lab/simple-csv-import-for-couchdb-71616200b095 might explain it a little better than I did. If you want I can make a bash script to automate it but it's pretty quick so I didn't think that was necessary.

roshanr10 commented 6 years ago

I'd prefer to not require a bash script... I was thinking more along the lines of a JavaScript file upload input that then converts to JSON and imports in the browser.

Requiring a team to use bash is kind of a pain, and this also means they must have internet access. File upload doesn't, it'll go straight to the local PouchDB.

roshanr10 commented 6 years ago

@nickdelta52 Do you think you could help with this? Skip the DB and match-specifics for now, but could you create a HTML5 document with a file upload form that takes takes a CSV, parses it into JSON, and calls a function?

For the following matches.csv:

team, points
4909, 1
811, 2

function handleCsvUpload(jsonData){}

jsonData = [{ "team": 4909, "points": 1 },{ "team": 811, "points": 2 }]

You can do this as a separate HTML file for now, and we can work on integration into a tab for it later.

nickdelta52 commented 6 years ago

@roshanr10 Sure, we can start working on this now, when do you want this done by?

roshanr10 commented 6 years ago

@nickdelta52 Awesome, would say next Wednesday be doable?

I know it's a short timeline, but the sooner the base is done, the more we can move onto more advanced features. Let me know if you think you'll need more time.

roshanr10 commented 6 years ago

Base CSV upload mechanism is posted here, and is ready to be integrated following the DB API: https://gist.github.com/nickdelta52/e9594710e6feec01e9e99d8b3f557b0e#file-csvparser-html