Skip to main content

An awesome package which helps us in creating a graph from Google Sheets and stores them as image

Project description

GSHEET_IMAGE_GENERATOR

Use of this API

An awesome package which helps us in creating a graph from Google Sheets and stores them as an image. The Graph is plotted by selecting two columns from the sheet i.e. for x-axis and y-axis.


Installation

pip install gsheet_image_generator

Log into the Google Developers Console with the Google account whose spreadsheets you want to access. Create (or select) a project and enable the Drive API and Sheets API (under Google Apps APIs).

Go to the Credentials for your project and create New credentials > OAuth client ID > of type Other. In the list of your OAuth 2.0 client IDs click Download JSON for the Client ID you just created. Save the file as client_secrets.json in your home directory (user directory). Another file named storage.json in this example, will be created after successful authorization to cache OAuth data. On your first usage of gsheet_image_generator with this file (holding the client secrets), your web browser will be opened, asking you to log in with your Google account to authorize this client read access to all its Google Drive files and Google Sheets.


How to use it?

Step 1

Open the Terminal and Run the below code to run the API. Pass the Path of the client_secrets.json while calling the Image_generator Class.

>>> from gsheet_image_generator.gsheet_image_generator import Image_generator
>>> Ig=Image_generator(Path)


After Running the above snippet you will see weather your request has granted or not, if granted then you will be asked to select the Spread Sheet from your Google Drive.

Select the respective number then the sheet will be Imported to your local computer.

You can Inspect the Spread Sheet by running the below command after creating an Object for Image_generator() class.

>>> Ig.sheet.head()

If you want to convert a Data type of a column then use the below function.

>>> Ig.convert_dtype(column, type_conversion)

The above function will take two arguments 1st is the column you want to convert and 2nd is Type to which you want to convert like('int', 'float' ,etc...)


If you want to convert a Timestamp column to DateTime then use the below function so that we can convert a timestamp dtype column to datetime dtype column.

>>> Ig.convert_timestamp_to_datetime()

The above function will ask you you select a column from the Dataframe.


If you want to generate year column from datetime column in your Data frame then use the below function.

>>>  Ig.generate_year()

If you want to generate month column from datetime column in your Data frame then use the below function.

>>>  Ig.generate_month()

If you want to generate day column from datetime column in your Data frame then use the below function.

>>>  Ig.generate_day()

If you want to group by entire Data frame on a particular column or liat of coluumns then use the below function.

>>>  Ig.groupby_column(column)

The above function will take one argument i.e either a single column or a more than one column passed as a list.

Generating Graphs as Images


If you want to plot a Line Graph and save it as an Image then Run the below commnad

>>> Ig.plot_line_graph()

By Running the above command you will be asked to select two columns i.e. One For the X-axis and the other one for Y-axis And it will ask you to enter the Path where you want to store the Image on your local computer.


If you want to plot a Bar Graph and save it as an Image then Run the below commnad

>>> Ig.plot_bar_graph()

By Running the above command you will be asked to select two columns i.e. One For the X-axis and the other one for Y-axis And it will ask you to enter the Path where you want to store the Image on your local computer.


If you want to plot a Box Plot and save it as an Image then Run the below commnad

>>> Ig.box_plot()

By Running the above command you will be asked to select two columns i.e. One For the X-axis and the other one for Y-axis And it will ask you to enter the Path where you want to store the Image on your local computer.


If you want to plot a Scatter Plot and save it as an Image then Run the below commnad

>>> Ig.scatter_plot()

By Running the above command you will be asked to select two columns i.e. One For the X-axis and the other one for Y-axis And it will ask you to enter the Path where you want to store the Image on your local computer.

See also


  • gsheets.py - self-contained script to dump all worksheets of a Google Spreadsheet to CSV or convert any sub sheet to a pandas DataFrame (Python 2 prototype for this library)
  • gspread - Google Spreadsheets Python API (more mature and featureful Python wrapper, currently using the XML-based legacy v3 API)

License

This Package is licensed under the MIT license. See License for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gsheet_image_generator-1.0.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

gsheet_image_generator-1.0.0-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page