How export all firestore data to excel of csv? - firebase

In my database has one users table in that table have many documents(users) in each documents have many subcollections. I want export all users table with all subcollections to excel or csv. Is it possible ? Can export all data ?
database users collection
image of one of the subcollection

To export data from Google Firestore, you can use the gcloud command-line tool to export your data as a JSON file.
Here are the steps to export data from Google Firestore:
Install the gcloud command-line tool, if you haven't already. You can find instructions for installing gcloud here: https://cloud.google.com/sdk/install
Open a terminal or command prompt and navigate to the directory where you want to save the exported data.
Use the following gcloud command to export your Firestore data:
gcloud firestore export gs://[BUCKET_NAME]
Finally you can use pandas or microsoft excel to convert exported json file into csv or excel
Specify file format using flag '--output-uri-prefix'
gcloud firestore export gs://[BUCKET_NAME] --output-uri-prefix=[OUTPUT_URI_PREFIX].json
Official Doc

Related

How to keep/re-create object metadata during gsutil cp on storage bucket

I would like to sync all of the files in my Google Cloud Storage bucket with the exported files in my Firebase Storage Emulator.
I downloaded all of my cloud files using gsutil to my local machine.
I used BeyondCompare to move all of the new files to the '../storage_export/blobs/ directory.
How do I update/create the JSON metadata in '../storage_export/metadata' to reflect these new files and make them available when I run the emulator and import them in?
Edit:
The gsutil docs mention the following:
when you download data from the cloud, it ends up in a file with no associated metadata, unless you have some way to keep or re-create that metadata.
How would one "keep" or "re-create" that metadata during a gsutil cp download?
You can use gsutil or the SDK to get each object's metadata and then write it down to a JSON file however, there's currently no native way to import Google Cloud Storage data in the Storage Emulator. But as I stated in my answer to this post, you can study how the emulator register the object by uploading sample files within the emulator and then running the export, you will see that the emulator will require 1 object and 1 JSON file that contains it's metadata.
Lastly, you can add the option --export-on-exit when starting the emulator, Downloaded all data from the real Firebase project, uploaded everything with the Emulator, then kill the emulator; as stated in this post.
Note: This is not a documented feature! Firebase doesn't expose the concept of download tokens in its public SDKs or APIs, so manipulating tokens this way feels a bit "hacky". For your further reference, check this post.

How do I start the Firebase Storage Emulator with production bucket data?

I'm using the Firebase Emulator to run all Firebase services. I have managed to run the emulator with a backup of my Firestore data by running:
firebase emulators:start --import ./my-directory
... but I can't find a way to do the same with my Storage data.
Firestore has an option to do import and export, while Firebase storage don't have this feature yet (storage uses upload and download). Currently, there's no native way to import Google Cloud Storage data in the Storage Emulator.
Additionally, you can study how the emulator register the object by uploading sample files within the emulator and then running the export, you will see that the emulator will require 1 object and 1 JSON file that contains it's metadata. For now, it'll be up to you to download the objects from your production bucket along with a separate JSON file containing its metadata and then structure it for import.
There's also an opened issue for this in github that you can monitor as well.
Although #RJC's answer is correct, I want to share what I did.
You can add the option --export-on-exit when starting the emulator, and it will export the state of the local Firebase instance to a folder of your choice. So I downloaded all my data from the real Firebase project, uploaded everything with the Emulator, then killed the emulator, everything (including storage) got exported and now I start it with the --import option using the same folder where I exported everything.
This was not very awful since I didn't that much stuff in my storage.

How do i import data to firebase that is in csv formate?

I have date in form of csv and have to upload to firebase for an application is it possible to connect a csv file to firebase project?
Is it possible to do a bulk insert in firebase insted of manually entering the data?

How to provide predefined data structure to Firebase Database

I need to put a default structure for some data in Firebase Database.
I'm developing a chat application using Firebase with a static list of chat groups.
There is a way to manually push the list of groups (with all the data fields needed already filled) or some others predefined data without using a mobile app or a website?
You can create the data structure as a JSON file and them import that JSON file into your Firebase Console.
Alternatively you can import the JSON file from a command line, using the Firebase CLI's database:set command.

How to export Firebase analytics data

I'm trying to figure out if it's possible to export all the Firebase Analytics data to an excel spreadsheet, similar to how you can do it with Google Analytics. From what I can find the only way to go about doing it is to link with BigQuery then do some SQL statements to build a table and export.
Unfortunately for us this is not going to work (due to client budget and capabilities). Is there any other way to export this data that I'm missing?
Update: You can now export the analytics reports as CSV from the Firebase console by clicking the Download CSV option from the ⠇ overflow menu.
In the meantime, you really should give BigQuery another look. The pricing is very reasonable and there is a free query tier of 1 TB/mo.
Steve Ganem
Product Manager, Firebase Analytics
As our company uses AWS for it's projects, BigQuery is not an option for now so I have moved on to scrape the data from Firebase.
You can use Selenium and Beautifulsoup in python to scrape the data from Firebase.
You could easily select and copy UI blocks on the Analytics web page in Firebase, and then just paste the copied data into an Excel sheet. You'll see fancy tables.
There is a YouTube video that explains and demonstrates the procedure here:
Copy Your Analytics Data to a Spreadsheet with this One WEIRD Trick! - Firecasts
For all those who use AWS and want an automated pipeline, BigQuery allows you to export CSV if you have no arrays and JSON if you do. You can then automate exports to google cloud storage. Finally, you can use Airflow with AWS or an EC2 with a CRON or some other orchestration or scheduling system to schedule the merging of the google data to your AWS pipeline.

Resources