Firebase - Data Upload



View the uploader files on Github

One of the key components of my application is the ability to search collections of items. My application has the ability to add data directly however I did not wish to do this for every single item. I found a couple of tutorials on how to upload data from CSV files to firebase that were extremely useful.

Step 1 - Gather your Data

  • Create an excel spread sheet with the first column named "objectId"
  • Make sure this matches the name in the uploader.js file exactly
  • Empty rows will cause errors as well as an empty "objefctId" field
  • Export your spreadsheet to csv
  • Step 2 - Format your Data

  • Export your CSV to JSON
  • Use something like CSVtoJson
  • Place your json file in the "file" folder, the name of your json file will be the name of the Firebase Collection
  • Step 3 - Set Up Firebase

  • Add Project on Firebase
  • Download Service Key for the project
  • Rename your service key to "service_key.json" and add it to the root project folder

    Set Up Node

  • NPM Init
  • NPM install firebase-admin
  • Upload Data

  • node uploader.js
  • Tricks/Tips/Errors

  • Remove your json from the "files" folder after running so you don't duplicate data
  • If you run into the error below delete .DS_store in the "files" folder



  • Sources

    This article on Medium - How to Upload Data to Firebase was a great resource or, if you prefer to watch a video, this one walks you through all the steps.