Import and Export into Googlesheet and AWS using R

Import and Export Googlesheet in R using GoogleSheet4 package
Recently I was working to sync some data from R to AWS S3 bucket and Googlesheet.

Problem Statement – R has retired the package googlesheet package and now you don’t have to use google authenticator each time you sync a sheet in R for any reporting.
Import and Export Googlesheet and AWS S3 bucket

Import and Export Googlesheet and AWS S3 bucket



Solution – Use googlesheet4 package

Problem 2 – There is a very little documentation for googlesheet4 package

Lets understand Import and Export Googlesheet and AWS S3 bucket in R using GoogleSheet4 package.

Here is a tried and tested solution from my side 🙂

Below are the packages you need for Google sheet

install.packages("googlesheets4")
library(googlesheets4)
library(googlesheets)
install.packages("RCurl")
library(RCurl)
Master_Sheet <- read_sheet("https://docs.google.com/spreadsheets/******",sheet = 'All')

url <- getURL(Master_Sheet)

Once you read the sheet, you can do your computation. Make sure that the final set which you want to upload in your Google sheet or AWS S3 Bucket is in a data frame

Creating my final set
Marketing_Cost <- rbind(A,B,S,C,V,A)

Rule 1
Change everything into a character, this is where you might get frustrated

Marketing_Campaign_Cost <- apply(Marketing_Campaign_Cost,2,as.character)

Rule 2
Convert the above in a data frame

MCC <- data.frame(Marketing_Campaign_Cost)

Rule 3
If you want to create a new sheet every time you run a code, then use
gs4_create
But rarely you would do so, most of the time you will be updating a sheet

xx <- write_sheet(
MCC,
ss = "https://docs.google.com/spreadsheets/d/TargetsheetLink",
sheet = "Global")

The above will write your data frame in your desired Googlesheet.
You can also write it in your local

write.csv(MCC,file=”/Users/oyo/abc.csv”)

What about AWS?

library(aws.s3)
Sys.setenv("AWS_ACCESS_KEY_ID" = "Your AWS Key ID","AWS_SECRET_ACCESS_KEY" = "Your AWS Secret Key Id")

s3write_using(MCC, FUN = write.csv,bucket = "Database Name", object = toString(paste("Link to folder/abc.csv",sep="")))

This way you will be able to import and export Googlesheet and AWS in R

Try to solve these questions, other members will evaluate your answer and provide sufficient support.

Walmart Labs- https://thedatamonk.com/walmart-data-analyst-questions/
American Express- https://thedatamonk.com/american-express-data-analyst-questions/
Barclays- https://thedatamonk.com/barclays-data-analyst-interview-questions/
Lowes- https://thedatamonk.com/lowes-data-science-interview-questions/
Factspan- https://thedatamonk.com/factspan-interview-questions/
Oracle- https://thedatamonk.com/oracle-data-analyst-interview-questions/
SAP- https://thedatamonk.com/sap-data-science-interview-questions/
Big Basket- https://thedatamonk.com/big-basket-data-analyst-interview-questions/
Swiggy – https://thedatamonk.com/swiggy-data-analyst-interview-questions/
Accenture – https://thedatamonk.com/accenture-business-analyst-interview-question/
Deloitte – https://thedatamonk.com/deloitte-data-scientist-interview-questions/
Amazon – https://thedatamonk.com/amazon-data-science-interview-questions/
Myntra – https://thedatamonk.com/myntra-data-science-interview-questions-2/
Flipkart – https://thedatamonk.com/flipkart-business-analyst-interview-questions/

The Data Monk Interview Books â€“ Don’t Miss

Now we are also available on our website where you can directly download the PDF of the topic you are interested in. At Amazon, each book costs ~299, on our website we have put it at a 60-80% discount. There are ~4000 solved interview questions prepared for you.

10 e-book bundle with 1400 interview questions spread across SQL, Python, Statistics, Case Studies, and Machine Learning Algorithms â€“ Ideal for 0-3 years experienced candidates

23 E-book with ~2000 interview questions spread across AWS, SQL, Python, 10+ ML algorithms, MS Excel, and Case Studies â€“ Complete Package for someone between 0 to 8 years of experience (The above 10 e-book bundle has a completely different set of e-books)

12 E-books for 12 Machine Learning algorithms with 1000+ interview questions â€“ For those candidates who want to include any Machine Learning Algorithm in their resume and to learn/revise the important concepts. These 12 e-books are a part of the 23 e-book package

Individual 50+ e-books on separate topics

Important Resources to crack interviews (Mostly Free)

There are a few things which might be very useful for your preparation

The Data Monk Youtube channel – Here you will get only those videos that are asked in interviews for Data Analysts, Data Scientists, Machine Learning Engineers, Business Intelligence Engineers, Analytics managers, etc.
Go through the watchlist which makes you uncomfortable:-

All the list of 200 videos
Complete Python Playlist for Data Science
Company-wise Data Science Interview Questions â€“ Must Watch
All important Machine Learning Algorithm with code in Python
Complete Python Numpy Playlist
Complete Python Pandas Playlist
SQL Complete Playlist
Case Study and Guesstimates Complete Playlist
Complete Playlist of Statistics

Author: TheDataMonk

I am the Co-Founder of The Data Monk. I have a total of 6+ years of analytics experience 3+ years at Mu Sigma 2 years at OYO 1 year and counting at The Data Monk I am an active trader and a logically sarcastic idiot :)