how to access a spreadsheets with python - python

so, I found this google spreadsheet and i really want to use it in combination with a telegram (TELEPOT) bot, to receive information of the weapon with a query given by the user, like:
elif text.startswith('/wiki'):
bot.sendChatAction(msg_data['chat_id'],action='typing')
item = text[6:]
bot.sendMessage(msg_data['chat_id'],'https://borderlands.fandom.com/wiki/'+item)
The spreadsheet Is not mine, And I have no idea how to access the json file with credentials

Related

Using python gspread delete a spreadsheet with Client.del_spreadsheet()

What is the easiest way to delete a sheet created by an API service account? Using the gspread API, I was able to create a sheet, and then share back to myself as editor. Now I can't delete because I am not the owner.
name = 'mysheet'
gc = gspread.service_account(filename=path_to_credentials)
try:
spreadsheet = gc.open(name)
except gspread.SpreadsheetNotFound:
spreadsheet = gc.create(name)
sharewith = 'me#myedu.edu'
spreadsheet.share(sharewith, perm_type='user',
notify=True, role='editor')
I want to reuse the service account credentials, but I am having trouble thinking about how to get the credentials in a Google OAuth object suitable to use with gspread.Client(). Below kind of resembles what I am thinking, but I feel I am missing something.
oa = gspread.oauth(credentials_filename=path_to_credentials)
c = gspread.Client(auth=oa)
c.del_spreadsheet('<spreadsheetId>')
If anyone has insights to offer, I would listen.

Access Firebase Realtime Database using Pyrebase

I have recently started with pyrebase and I am having trouble in storing data depending on user and receiving it. After completing the authentication part I create a user ID as user['idToken']
And then pushed data by using
archer = {"name": "Sterling Archer", "agency": "Figgis Agency"}
db.child("agents").push(archer, user['idToken'])
I assume that each user has different ID token which remains same even if we logout and relogin. but when I am using
all_agents = db.child("agents").get(user['idToken']).val()
print(all_agentes)
It's printing all data stored in realtime database. Even which were stored by other users.
I tried reading all it's documentation, but I was unable to understand how to handle it.
What's wrong that I am doing in here and How can I correct it?
Use user[localId] instead of user[idToken] as it will create database for every different user separately

Check if spreadsheet exists

I'm developing an application that saves an acquired value to a google spreadsheet. I would like to know if I can do following things via google-spreadsheet API while using python
Check if a spreadsheet exists with given name
Get a list of spreadsheets while requesting via name or id
Thanks in advance!

Is there a way to call from Google Sheets (Or MySQL) with Discord.py?

I have this idea on my Discord Server which would allows people to do
?playtime [TheirID]
and it would display their playtime as a reply by my BOT(I am talking about their Unturned Server Playtime, which is explained below:)
Everyone's Unturned Server Playtime is stored in a Google Sheets table (It is also stored in a MySQL database), so is there a way to allow them to do ?Playtime and then their ID, it searches their ID, finds the row they are in and then embeds the whole row into a reply by the bot?
Any help will be appreciated, if you are confused please ask me more questions.
Use the Google Sheets API
It works well for discord bots

Unable to get campaigns data to push to database in google adwords api

I am facing a couple of issues in figuring out what-is-what, in spite of the humungous documentation I am unable to figure out these issues
1.Which report type should be used to get the campaign level totals. I am trying to get the data in the format of headers
-campaign_id|campaign_name|CLicks|Impressions|Cost|Conversions.
2.I have tried to use "CAMPAIGN_PERFORMANCE_REPORT" but I get broken up information at a keyword level, but I am trying to pull the data at a campaign level.
3.I also need to push the data to a database. In the API documentation, i get samples which will either print the results on my screen or it will create a file on my machine. is there a way where I can get the data in JSON to push it to the database.
4.I have 7 accounts on my MCC account as of now, the number will increase in the coming days. I don't want to manually hard code the client customer ids into my code as there will be new accounts which will be created. is there a way where I can get the list of client customer ids which are on my MCC ac
I am trying to get this data using python as my code base and adwords api V201710.
To retrieve campaign performance data you need to run a campaign_performance_report. Follow this link to view all available columns for Campaign performance report.
The campaign performance report does not include stats aggregated at a keyword level. Are you using AWQL to pull your report?
Can you paste your code here, I find it odd you are getting keyword level data.
Run this python example code to get campaign data (you should definitely not be getting keyword level data with this example code).
Firstly Google AdWords API only returns report data in the following file formats CSVFOREXCEL, CSV, TSV, XML, GZIPPED_CSV, GZIPPED_XML. Unfortunately JSON is not supported for your use case. I would recommend GZIPPED_CSV and set the following properties to false:
skipReportHeader
skipColumnHeader
skipReportSummary
This will simply skip all headers, report titles & totals from the report making is very simple to upsert data into a table.
It is not possible to enter a MCC ID and expect the API to fetch a report for all client accounts. Each API report request contains the client ID, so therefore you are required to create an array of all client IDs and then iterate through each id. If you are using the client library (recommended) then you can simply set the clientID within the session i.e. session.setClientCustomerId("xxx");
To automate this use the ManagedCustomerService to automatically retrieve all clientIDs then iterate through this therefore you would not need to hard code each ClientID. Google have created a handy python file which returns the account hierarchy including child account ID (click here).
Lastly I based on your question I assume you attempting to run an ETL process. Google have an opensource AdWords extractor which I highly recommend.

Categories