How to import Google Sheets Data Into MongoDB from any link? - reactjs

Context
I'm a web development beginner building a MERN stack web-app to help school clubs manage applicants. I want users to be able to input a link to Google Sheet generated from their Google Form and be able to see a cleaner, properly formatted version of their data.
Exploration
From my research, it looks like most solutions:
Involve people wanting to automate their own sheets (and therefore being able to use the Google Sheets script editor)
Make use of Tabletop.js, which will soon be deprecated. I looked into PapaParse but really couldn't figure out how to solve my problem using it.
Use MongoDB Stitch, which also relies on accessing the Google Sheets script editor
Require users to download the file as a CSV file (which is non-ideal for live updates)
It also seems like the Google Sheets API requires the user to have access to the script editor? I might not be interpreting the docs correctly. Would having users authenticate/login to my web app through Google be able to overcome this problem?
My Goal
User pastes the link to their Google Sheets (with view access or published to the web) in my React app
My React app parses the Sheets data and stores it in MongoDB Atlas
[Optional] Update the MongoDB database whenever the original sheet is updated (There is no need for MongoDB to communicate back with the sheet.)
Thank you, any help is much appreciated!

Try out Zapier.
It has a Google Sheets + MongoDB integration.
https://zapier.com/apps/google-sheets/integrations/mongodb
One way you could possibly achieve this is to:
link your Google Sheets account to Zapier, then
collect the links through your React app,
duplicate the sheet from that link
set Zapier to watch for that trigger when a new sheet is duplicated, to pass on the data to MongoDB

Related

Fetch data from google sheet using React

I would like to fetch data from the google sheet with React.
I tried to use the following libraries
https://github.com/ruucm/react-google-sheets
https://github.com/gglukmann/use-google-sheets
However, it always requires setting the file permission to "Anyone with this link can view". We don't want to share the file outside our org. If we do this, the client cannot read the data from google sheet.
Is there any way that I can fetch data from a restricted google sheet? Thank you
You need to use the Google Sheets API to connect to the Sheet and fetch the data.
The application would need to be authorised to run as the person who owns or is an editor of the sheet. Check out the node.js quickstart for setting up an application in the cloud console. The method you need to get data is spreadsheets.values.get.

Can Google Sheets be used as "Multi-user" database?

Say I have an App and I want to use Google sheet as my backend database.
Can I let the different users use their own Google sheets by logging in their own Google account?
I read some articles about using Google sheet as a backend database, but almost all of them are about creating the Google sheet with your own Google account.
I know Google Drive can let you save user-specific data to user's own space. I am not sure if Google Sheets can do a similar thing.
that's a very abstract question, but yes (it depends). after that, all you need to do is collect all the data into a master spreadsheet with IMPORTRANGE formulas:
=IMPORTRANGE("URL-or-ID", "Sheet1!A1:Z")

Google Cloud Datastore and reports/administration

I'm quite new to Google App Engine and it's cloud Datastore which is used for storing the backend's data by default. As far as I realized you can only view it's content within the developer console and you can create or edit entities there.
But is there any external tool from which you can connect to your datastore to create reports or administer the data? What is your experience?
In fact yes it's true you can only see data's from the admin console.
If you wish to see your data's in Google Drive Table and make a report you can, but for that you need to create a connector to your sheet (I already made one). It's exactly the same if you need update or import data's to your datastore.
I use this Technic to upload or refresh products on my e-shop GAE app.
In general if I need to see a report, I design a specific web page for that and I protect theme via a login / password. To see a well formatted report you can use jquery library or use Google Charts

Google App Engine and Shared Google Spreadshhet

I have project that is coming along nicely. I can now read and edit my Google spreadsheet using my Google App Engine App. I set up sharing in the spreadsheet giving edit permissions to myapplicaton#appspot.gserviceaccount.com
If everything works as I hope I will someday get customers that will be able to also share their spreadsheets and will be able read and edit their spreadsheets using my application.
I can see in the Google App Engine Logs which spreadsheets are being accessed using my program but I was hoping for a little more.
Is there a way for me to know all of the spreadsheets that have given my application permission to edit them?
Is there a way to refuse edit shares if I find out that one of these spreadsheets is abusing my application's terms of use etc.
Using the drive api you can see files shared with you. But it seems you only care for people abusing your system and those you already detect since they have to go through your appengine frontend.

Developing for Google App Engine and using the datastore

I am just getting started with Google Web Toolkit and Google App Engine and have a quick question. I think I understand how to use the datastore now but I was wondering if there is a way that I can quickly create a "database" with static data from an excel sheet? I just need to add some data for a proof of concept later this week.
I am picturing something similar to a SQL database browser where I can just import the data?
I developing in Eclipse with appropriate plugins.
Thanks,
Rob
The easiest way to do this would be to save your spreadsheet as a CSV file, then use the bulkloader to load it into the datastore.
Your best bet is probably to write something to handle uploading it, or to handle processing it on the server.
However, you should also look at the bulk loader. It might be able to save you a little bit of time.
Here is the API (Google Documents List API) that "allows client applications to programmatically access and manipulate user data stored with Google Documents".

Resources