How to save an excel file with DataNitro and python - python

I've got an python script to that generates an excel worksheet from a database query with the DataNitro excel plugin (the free one), now i want so save the file and then send it via email, but the DataNitro docs only includes working with cells and worksheets, is there a method call in the DataNitro API or any other work around to save the file?

DataNitro founder here - I've just added the functions to save workbooks to the DataNitro API for you. Thanks for point this out! You need to download the latest version of DataNitro from https://www.datanitro.com
Here's the Python 2 code to save a workbook & send it via email: https://github.com/datanitro/blog/blob/master/save_and_email/save_and_send.py
You can find the documentation for save() and save_copy() here: https://datanitro.com/docs.html#sheets
Please let me know what you think. Thanks!

I think you're looking for something like smtplib. This will allow you to send emails and attachments from python.
Find out more here:
http://www.blog.pythonlibrary.org/2010/05/14/how-to-send-email-with-python/
Documentation:
http://docs.python.org/library/smtplib.html

Related

Updating Google sheets using python or appscripts

Is there any way i can automatically update my google sheets data Using appscripts or Python?
Right now, I have access(through Gmail) to download it using a link, It downloads a csv file which I later Update in google sheets.
Any Help? Suggestion ? Advice?
Tried using scripts, but doesnot update for some reason.

Need help converting google sheet to pandas dataframe, without google API or public viewing setting

So I'm able to use the googlesheets4 package in R to read a google sheet, but I'm unable to use pandas.read_csv(url) to read a google sheet. Using read_csv returns HTML(which seems to be because it's redirecting to an authorization page), when I set the google sheet to public, read_csv works.
This is for work, and the sheets are set to anyone in organization and view with link.
Anyone able to help?
My thought is that if a package in R can do it, that there must be a way in Python as well.

Saving Spreadsheet to Folder in Google Sheets API (Python)

I am working with the Google Sheets API in Python but am having trouble finding out how to save a newly created Spreadsheet to a specific folder. As of now all it does is populate my drive without the ability to indicate an end location. Any idea how to do this in Python?
I have found help with other languages but the python documentation is much different. Any insight would be great...

Persistent SpreadsheetNotFound errors on specific Google Sheets spreadsheets in gspread for Python

I am using gspread to collect data from several hundred Google Sheets spreadsheets. I parse the files stored by Google Drive in a local directory and obtain the URLs for all the spreadsheets within a specified folder. Then I use a python wrapper to go through the URLs and a shell script wrapper to jump start the python wrapper when the connection glitches out.
One of the causes for the glitches is the SpreadsheetNotFound error. I did a quick check about halfway through and found that 21/139 (~15%) of my spreadsheets always get this error (I have it skip the spreadsheet if it's not found five times). I have gone in with iPython and manually tested these with open_by_url, open_by_key, and open (with the title), but they all return the same SpreadsheetNotFound error. The most frustrating part is being able to copy the URL directly from my error message, pasting it in the browser, and the browser going straight to the spreadsheet without a problem. The second most frustrating part is that it works beautifully for ~85% of the spreadsheets, but 85% is not exactly going to cut it.
I'm not even sure this is solvable. I'm just curious if anyone else out there has had this problem with gspread.
Thanks for any feedback.
Edit 1: Hm, the failing spreadsheets were all created prior to 2/2/15. The older sheets have been updated to the newest version of Drive - that may have had an effect on the API.
From the Gspread docs:
ClientLogin is deprecated:
https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1
Authorization with email and password will stop working on April 20, 2015.
Please use oAuth2 authorization instead:
http://gspread.readthedocs.org/en/latest/oauth2.html
So I assume you're using oAuth2. Which means you need to add the email address in that json cert file to the spreadsheet.
Using OAuth2 for Authorization
See point #7:
Go to Google Sheets and share your spreadsheet with an email you have
in your json_key['client_email']. Otherwise you’ll get a
SpreadsheetNotFound exception when trying to open it.

Form through Email that can be Parsed Using Python

I want to email out a document that will be filled in by many people and emailed back to me. I will then parse the responses using Python and load them into my database.
What is the best format to send out the initial document in?
I was thinking an interactive .pdf but do not want to have to pay for Adobe XI. Alternatively maybe a .html file but I'm not sure how easy it is to save the state of it once its been filled in in order to be emailed back to me. A .xls file may also be a solution but I'm leaning away from it simply because it would not be a particularly professional looking format.
The key points are:
Answers can be easily parsed using Python
The format should common enough to open on most computers
The document should look relatively pleasing to the eye
Send them a web-page with a FORM section, complete with some Javascript to grab the contents of the controls and send them to you (e.g. in JSON format) when they press "submit".
Another option is to set it up as a web application. There are several Python web frameworks that could be used for that. You could then e-mail people a link to the web-app.
Why don't you use Google Docs for the form. Create the form in Google Docs and save the answer in an excel sheet. And then use any python Excel format reader (Google them) to read the file. This way you don't need to parse through mails and will be performance friendly too. Or you could just make a simple form using AppEngine and save the data directly to the database.

Categories