Package: gsheet-image-generator
GSHEET_IMAGE_GENERATORUse of this APIAn 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.Installationpipinstallgsheet_image_generatorLog into theGoogle Developers Consolewith the Google account whose
spreadsheets you want to access. Create (or select) a project and enable theDrive APIandSheets API(underGoogle Apps APIs).Go to theCredentialsfor your project and createNew credentials>OAuth client ID> of typeOther. In the list of yourOAuth 2.0 client IDsclickDownload JSONfor the Client ID you just created. Save the file asclient_secrets.jsonin your home directory (user directory). Another file namedstorage.jsonin this example, will be created after successful authorization to cache OAuth data.
On your first usage ofgsheet_image_generatorwith 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 1Open the Terminal and Run the below code to run the API.
Pass the Path of theclient_secrets.jsonwhile calling theImage_generatorClass.>>>fromgsheet_image_generator.gsheet_image_generatorimportImage_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 yourGoogle 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 forImage_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 ImagesIf 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 alsogsheets.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-basedlegacy v3 API)LicenseThis Package is licensed under the MIT license. See License for details.