Ejemplo n.º 1
0
def getData(sheet):
    CLIENT_SECRET_FILE = 'credentials.json'
    API_SERVICE_NAME = 'sheets'
    API_VERSION = 'v4'
    SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']

    s = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                       SCOPES)
    gs = s.spreadsheets()

    rows = gs.values().get(spreadsheetId=sheet, range='Alumnos').execute()
    return rows.get('values')
Ejemplo n.º 2
0
def gsheet_to_df(gsheetId, scope):
    CLIENT_SECRET_FILE = 'client_secret.json'
    API_SERVICE_NAME = 'sheets'
    API_VERSION = 'v4'
    SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
    s = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                       SCOPES)
    gs = s.spreadsheets()
    rows = gs.values().get(spreadsheetId=gsheetId, range=scope).execute()
    header = rows.get('values', [])[0]  # Assumes first line is header!
    values = rows.get('values', [])[1:]  # Everything else is data.
    df = pd.DataFrame(values, columns=header)
    return df
Ejemplo n.º 3
0
def df_to_gsheet(df, gsheetId, scope='Arkusz1'):
    CLIENT_SECRET_FILE = 'client_secret.json'
    API_SERVICE_NAME = 'sheets'
    API_VERSION = 'v4'
    SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
    service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                             SCOPES)
    df.replace(np.nan, '', inplace=True)
    response_date = service.spreadsheets().values().append(
        spreadsheetId=gsheetId,
        valueInputOption='RAW',
        range=scope + '!A1',
        body=dict(majorDimension='ROWS',
                  values=df.T.reset_index().T.values.tolist())).execute()
Ejemplo n.º 4
0
def getName():

    CLIENT_SECRET_FILE = 'client_secret.json'
    API_SERVICE_NAME = 'sheets'
    API_VERSION = 'v4'
    SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
    gsheetId = '1H3KBMR6J5UBxQStSi1GGUbnHiG5MMSsVBO1if2MsKQk'

    s = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                       SCOPES)
    gs = s.spreadsheets()
    rows = gs.values().get(spreadsheetId=gsheetId,
                           range='Government Agencies').execute()
    data = rows.get('values')
    df = pd.DataFrame(data)
    return (df[0] + ' ' + df[1])
# Arquivo JSon com Client ID autorizando escrita no Google Sheets:
CLIENT_SECRET_FILE = '<PATH TO CLIENT SECRET JSON FILE>'

# DataFrame de exemplo:
df = pd.DataFrame(columns=['lib', 'qty1', 'qty2'])
for i in range(200):
    df.loc[i] = ['name' + str(i)] + list(randint(10, size=2))

API_SERVICE_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']

service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                         SCOPES)

spreadsheets = service.spreadsheets()


def add_sheets(gsheet_id, sheet_name):
    try:
        request_body = {
            'requests': [{
                'addSheet': {
                    'properties': {
                        'title': sheet_name,
                        'tabColor': {
                            'red': 0.44,
                            'green': 0.99,
                            'blue': 0.50
                        }
                    }
Ejemplo n.º 6
0
API_SERVICE_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']

service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                         SCOPES)

month = datetime.now().month
year = datetime.now().year
spreadsheet_body = {
    'properties': {
        'title': f"{datetime.now().strftime('%B-%Y')} statistics"
    }
}

sheet = service.spreadsheets().create(body=spreadsheet_body).execute()

spread_id = sheet['spreadsheetId']
worksheet_name = 'Sheet1!'

cell_range_insert = 'A1'


def set_bold_and_center(service_object, row):
    body_bold = {
        "requests": [{
            "repeatCell": {
                "range": {
                    "sheetId": 0,
                    "startRowIndex": row - 1,
                    "endRowIndex": row,
Ejemplo n.º 7
0
import main
from Google import Create_Service
from google_auth_oauthlib.flow import InstalledAppFlow
import pandas as pd
import numpy as np
df = main.sql_query
CLIENT_SECRET_FILE = 'test02032020-f96bd03b9833.json'
API_SERVICE_NAME = 'Sheet1'
API_VERSION = 'v4'

SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
gsheetId = '1pDgRzqyU6LxG-hahZjKQ658mT26rTk_ku8-BAWNmB9s'
service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                         SCOPES)
response_date = service.spreadsheets().values().append(
    spreadsheetId=gsheetId,
    valueInputOption='RAW',
    range='DF1!A1',
    body=dict(majorDimension='ROWS',
              values=df.T.reset_index().T.values.tolist())).execute()
#
# # df.to
Ejemplo n.º 8
0
def upload():
    pythoncom.CoInitialize()
    if request.method == "POST":
        xlApp = win32.Dispatch('Excel.Application')
        if request.files:
            file = request.files["excel"]
            sheetid = request.form['sheetid']
            sname = request.form['sheetname']
            estart = request.form['estart']
            gstart = request.form['gstart']
            print(sheetid)
            if file.filename == "":
                flash('File must have a filename')
                return redirect(request.url)
            if sheetid == "" or sname == "" or estart == "" or gstart == "":
                flash('All Fields must be Filled')
                return redirect(request.url)
            if not checkFile(file.filename):
                flash("File Extension not Supported")
                return redirect(request.url)
            else:
                filename = secure_filename(file.filename)
                print(filename)
                file.save(os.path.join(os.getcwd()+'/files', filename))
                xlApp = win32.Dispatch('Excel.Application')
                wb = xlApp.Workbooks.Open(r""+app.config["FILE_UPLOAD"]+"/"+filename)
                print(wb)
                try:
                    ws = wb.Worksheets(sname)
                except Exception as e:
                    flash("Error opening worksheet")
                    return redirect(request.url)
                rngData = ws.Range(estart).CurrentRegion()

                #191h4mt1-iSzIdeRdbszAcWaV_m7_gbierp_bLImnWnI
                gsheet_id = sheetid
                CLIENT_SECRET_FILE = 'client_token.json'
                API_SERVICE_NAME = 'sheets'
                API_VERSION = 'v4'
                SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
                service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION, SCOPES)

                try:
                    response = service.spreadsheets().values().append(
                        spreadsheetId=gsheet_id,
                        valueInputOption='RAW',
                        range='data!'+gstart,
                        body=dict(
                            majorDimension='ROWS',
                            values=rngData
                        )
                    ).execute()                    
                except Exception as e:
                    print('Error Uploading to google sheets: '+ str(e))
                    return redirect(request.url)

                for proc in psutil.process_iter():
                    if proc.name() == 'EXCEL.EXE':
                        proc.kill()
                flash("Uploaded")
                return redirect(request.url)

               
    return render_template("index.htm")
    def clicked(self):  #For first tab
        #Taking inputs from the screen
        spreadsheet_id1 = str(self.lineEdit.text())
        spreadsheet_id2 = str(self.lineEdit_2.text())
        spreadsheet_id3 = str(self.lineEdit_3.text())
        spreadsheet_id4 = str(self.lineEdit_4.text())
        wshop = str(self.lineEdit_5.text())
        year = str(self.lineEdit_6.text())

        message = QtWidgets.QMessageBox.about(
            self, 'Info', 'Wait until Unique IDs are generated')
        #Using Google API
        CLIENT_SECRET_FILE = 'Oauth Credentials.json'
        API_NAME = 'sheets'
        API_VERSION = 'v4'
        SCOPES = ['https://www.googleapis.com/auth/spreadsheets']

        service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION,
                                 SCOPES)
        final = []

        if spreadsheet_id1 != 'None':
            final.append(spreadsheet_id1)

        if spreadsheet_id2 != 'None':
            final.append(spreadsheet_id2)

        if spreadsheet_id3 != 'None':
            final.append(spreadsheet_id3)

        if spreadsheet_id4 != 'None':
            final.append(spreadsheet_id4)

        flist = []
        #To read data from sheets and store in list for faster access
        if len(final) == 3:
            total1 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id1,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total1 = total1['values']
            count = len(total1)
            total2 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id2,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total2 = total2['values']
            total3 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id3,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total3 = total3['values']
            i = -1
            while (i < count - 1):
                i += 1
                if (total1[i] in total2) and (total1[i] in total3) and (
                    (total1[i] not in flist) or (flist == [])):
                    flist.append(total1[i])
                else:
                    continue

        elif len(final) == 2:
            total1 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id1,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total1 = total1['values']
            count = len(total1['values'])
            total2 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id2,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total2 = total2['values']
            i = -1
            while (i < count - 1):
                i += 1
                if (total1[i] in total2) and ((total1[i] not in flist) or
                                              (flist == [])):
                    flist.append(total1[i])
                else:
                    continue

        elif len(final) == 4:
            total1 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id1,
                range='Sheet1',
                majorDimension='ROWS')
            total1 = total1.execute()
            total1 = total1['values']
            count = len(total1['values'])
            total2 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id2,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total2 = total2['values']
            total3 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id3,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total3 = total3['values']
            total4 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id4,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total4 = total4['values']
            i = -1
            while (i < count - 1):
                i += 1
                if (total1[i] in total2) and (total1[i] in total3) and (
                        total1[i] in total4) and ((total1[i] not in flist)
                                                  or flist == []):
                    flist.append(total1[i])
                else:
                    continue

        elif len(final) == 1:
            total1 = service.spreadsheets().values().get(
                spreadsheetId=spreadsheet_id1,
                range='Sheet1',
                majorDimension='ROWS').execute()
            total1 = total1['values']
            count = len(total1['values'])
            i = -1
            while (i < count - 1):
                i += 1
                if ((total1[i] not in flist) or flist == []):
                    flist.append(total1[i])

        #Creating new spreadsheet
        properties = {'properties': {'title': 'Final Sheet' + wshop}}
        fspreadsheet = service.spreadsheets().create(
            body=properties, fields='spreadsheetId').execute()
        fspreadsheet_id = fspreadsheet['spreadsheetId']
        i = 1
        while (i <= len(flist)):
            frange = 'A' + str(i) + ':' + 'C' + str(i)
            values = [flist[i - 1]]
            value_range_body = {'majorDimension': 'ROWS', 'values': values}
            request2 = service.spreadsheets().values().append(
                spreadsheetId=fspreadsheet_id,
                range=frange,
                valueInputOption='RAW',
                insertDataOption='OVERWRITE',
                body=value_range_body)
            response = request2.execute()
            i += 1

        part1 = wshop
        part2 = year[-2:]
        uqids = dict()

        participants = service.spreadsheets().values().get(
            spreadsheetId=fspreadsheet_id,
            range='Sheet1',
            majorDimension='ROWS').execute()
        participants = len(participants['values'])
        i = 1
        #Will be generating Unique IDs for all participants
        while (i <= participants):

            range = 'A' + str(i) + ':' + 'C' + str(i)
            request = service.spreadsheets().values().get(
                spreadsheetId=fspreadsheet_id,
                range=range,
                valueRenderOption='FORMATTED_VALUE',
                majorDimension='ROWS',
                dateTimeRenderOption='SERIAL_NUMBER')

            values = request.execute()
            name = values['values'][0][0]

            part3 = str(random.randrange(00000, 99999))
            part3 = part3.zfill(5)
            uqid = part1 + '_' + part2 + '_' + part3
            if name == 'Name ':
                values = [['Unique_ID']]

            elif (name not in uqids.keys()
                  or uqids.keys() is None) and (uqid not in uqids.values()
                                                or uqids.values() is None):
                uqids[name] = uqid
                values = [[uqid]]

            value_range_body = {'majorDimension': 'ROWS', 'values': values}
            range2 = 'D' + str(i)
            #Updating the generated Unique IDs in newly created sheet
            request2 = service.spreadsheets().values().append(
                spreadsheetId=fspreadsheet_id,
                range=range2,
                valueInputOption='RAW',
                insertDataOption='OVERWRITE',
                body=value_range_body).execute()

            i += 1

        message2 = QtWidgets.QMessageBox.about(self, 'Info',
                                               'All Unique IDs are generated')
Ejemplo n.º 10
0
FOLDER_PATH = r'<C:\Users\asus\Downloads>'
CLIENT_SECRET_FILE = os.path.join('Client_Secret.json')
API_SERVICE_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']

service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                         SCOPES)
"""
Blank Spreadsheet File
"""
"""
dict_keys(['spreadsheetId','properties','sheets','spreadsheetUrl'])
"""
sheets_file1 = service.spreadsheets().create().execute()

pprint(sheets_file1['spreadsheetUrl'])
pprint(sheets_file1['sheets'])
pprint(sheets_file1['spreadsheetId'])
pprint(sheets_file1['properties'])
"""
Advanced Example: Spreadsheet File with some default settings
"""

sheet_body = {
    'properties': {
        'title': 'My First Google Sheet File',
        'locale': 'en_US',
        'timeZone': 'America/Los_Angeles',
        'autoRecalc': 'HOUR'
Ejemplo n.º 11
0
                    }
                },
                'fields':
                'userEnteredFormat(numberFormat, backgroundColor, textFormat)'
            }
        },
        {
            'repeatCell': {
                'range': {
                    'sheetId': sheet_id,
                    'startRowIndex': 2,
                    'endRowIndex': 11,
                    'startColumnIndex': 3,
                    'endColumnIndex': 4
                },
                'cell': {
                    'userEnteredFormat': {
                        'numberFormat': {
                            'type': 'Number',
                            'pattern': '#,##0'
                        }
                    }
                },
                'fields': 'userEnteredFormat(numberFormat)'
            }
        }
    ]
}

response = service.spreadsheets().batchUpdate(spreadsheetId=spreadsheet_id,
                                              body=request_body).execute()
import os
from Google import Create_Service
from pprint import pprint

FOLDER_PATH = r'<C:\Users\asus\Downloads>'
CLIENT_SECRET_FILE = os.path.join('Client_Secret.json')
API_SERVICE_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']

service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                         SCOPES)

spreadsheet_id = '1z1OtLpjSd7KJnnzTyjBPUs6x7Ei_ELmhH2B09wQlvjU'
mySpreadsheet = service.spreadsheets().get(
    spreadsheetId=spreadsheet_id).execute()
"""
------------------------------
"""

worksheet_name = 'Sales North!'
cell_range_insert = 'B2'
values = (('Col A', 'Col B', 'Col C', 'Col D'), ('Apple', 'Orange',
                                                 'Watermelon', 'Banana'))
value_range_body = {'majorDimension': 'COLUMNS', 'values': values}

service.spreadsheets().values().update(spreadsheetId=spreadsheet_id,
                                       valueInputOption='USER_ENTERED',
                                       range=worksheet_name +
                                       cell_range_insert,
                                       body=value_range_body).execute()
Ejemplo n.º 13
0
                id = temp[6]
                name = pokemon['name']
                timestamp = (datetime.now().strftime('%Y-%m-%d - %H:%M:%S'))
                poks.append([id, name, url, timestamp])
                print(id, name, url, timestamp)

        next = input("Next page? [Y/N]")
        if next == ('y'):
            pokedex(offset=offset + 20)


if __name__ == '__main__':
    url = 'https://pokeapi.co/api/v2/pokemon/'
    pokedex()
    CLIENT_SECRET_FILE = 'client_secret.json'
    API_NAME = 'sheets'
    API_VERSION = 'v4'
    SCOPES = ['https://www.googleapis.com/auth/spreadsheets']

    service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)

    spreadsheet_id = '1jrdWy6kOHzz9gjEuqgJFUnpnYnDb19-zB77XWbMOpeg'

    cell_range_insert = 'A1'
    value_range_body = {'majorDimension': 'ROWS', 'values': poks}

    service.spreadsheets().values().update(spreadsheetId=spreadsheet_id,
                                           valueInputOption='USER_ENTERED',
                                           range=cell_range_insert,
                                           body=value_range_body).execute()
# ).execute()
#
# pprint(response)
# # pprint(response.keys())
# # pprint(response['range'])
# # pprint(response['majorDimension'])
# # pprint(response['values'])
#
# columns = response['values'][0]
# data = response['values'][1:]
# df = pd.DataFrame(data, columns=columns)
#
# pprint(df)
#
# df2 = df.set_index('Invoice')
# pprint(df2)
"""
Example 1. Get method 
"""

response = service.spreadsheets().values().get(spreadsheetId=spreadsheet_id,
                                               majorDimension='ROWS',
                                               range='Sales North').execute()

pprint(response['values'])

columns = response['values'][1][1:]
data = [item[1:] for item in response['values'][2:]]
df = pd.DataFrame(data, columns=columns)
pprint(df)
Ejemplo n.º 15
0
import win32com.client as win32
from Google import Create_Service

xlApp = win32.Dispatch('Excel.Application')
wb = xlApp.Workbooks.Open(
    r'C:\Users\jjenn\Documents\Python\win32com\Dataset\champion_list.xlsx')
wsData = wb.Worksheets('Worksheet')
rngdata = wsData.Range('A1').CurrentRegion

CLIENT_SECRET_FILE = 'client_secret.json'
API_SERVICE_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
service = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION,
                         SCOPES)

gsheet_id = '1iD0w4OQBdNTNV78XVwbRUyopJLgkdtneEkbVwTZqukk'

response_date = service.spreadsheets().values().append(
    spreadsheetId=gsheet_id,
    valueInputOption='RAW',
    range='xlData!A1',
    body=dict(majorDimension='ROWS', values=rngdata.value)).execute()
Ejemplo n.º 16
0
gsheetId = '1mZghpSk7wSh0sOy3s_Mg9bxtSW2Am3Y8UUubND9y0Ng'


def get_symbol_value_by_date(symbol, date=datetime.datetime.now()):
    date1 = date + datetime.timedelta(days=1)
    data = yf.download(symbol,
                       start=date.strftime("%Y-%m-%d"),
                       end=date1.strftime("%Y-%m-%d"),
                       progress=False)
    # pdb.set_trace()
    value = data['Close'].values[0]
    return value


s = Create_Service(CLIENT_SECRET_FILE, API_SERVICE_NAME, API_VERSION, SCOPES)
gs = s.spreadsheets()
rows = gs.values().get(spreadsheetId=gsheetId, range='Sheet1').execute()
data = rows.get('values')
df = pd.DataFrame(data,
                  columns=[
                      'Ticker', 'Buy zone target 3', 'Buy zone target 2',
                      'Buy zone target 1'
                  ])
#print(df['Ticker'])
for key, value in df.iterrows():
    #print(value['Ticker'])
    curr_value = get_symbol_value_by_date(str(value['Ticker']),
                                          date=datetime.datetime.now())
    print(curr_value, value['Buy zone target 3'])
    if float(curr_value) <= float(
            value['Buy zone target 3']) and float(curr_value) >= float(
Ejemplo n.º 17
0
import re
import datetime
from datetime import timedelta
from secret import sheets_id

CLIENT_SECRET_FILE = 'credentials.json'
API_NAME = 'sheets'
API_VERSION = 'v4'
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']

service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)

spreadsheet_id = sheets_id

result = service.spreadsheets().values().get(spreadsheetId=spreadsheet_id,
                                             majorDimension='ROWS',
                                             range='A1:R').execute()

# DataFrame
columns = result['values'][0]
data = result['values'][1:]
df = pd.DataFrame(data, columns=columns)
pd.set_option('display.max_columns', None)

# Change Date Format
df['Submitted At'] = pd.to_datetime(df['Submitted At']).dt.normalize()

# Clean Up Manufacturers Data
df['Manufacturer'][df['Manufacturer'] ==
                   'Manufacturer not listed below'] = df['< text field']
    def clicked2(self):  #For Certificate Generation
        #Using Google APIs
        CLIENT_SECRET_FILE = 'Oauth Credentials.json'
        API_NAME = 'sheets'
        API_VERSION = 'v4'
        SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
        service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION,
                                 SCOPES)
        CLIENT_SECRET_FILE1 = 'Oauth Credentials.json'
        API_NAME1 = 'drive'
        API_VERSION1 = 'v3'
        SCOPES1 = ['https://www.googleapis.com/auth/drive']
        service1 = Create_Service(CLIENT_SECRET_FILE1, API_NAME1, API_VERSION1,
                                  SCOPES1)

        #Taking input from the screen
        fspreadsheet_id = str(self.lineEdit_7.text())
        workshop = str(self.lineEdit_8.text())

        name_f = str(self.lineEdit_9.text())
        name_cs = str(self.lineEdit_11.text())
        name_cs = name_cs.split(',')
        name_c = list()
        for i in range(len(name_cs)):
            name_c.append(int(name_cs[i]))
        name_c = tuple(name_c)
        ycoord = int(str(self.lineEdit_10.text())
                     )  #For determining position of Name on template
        content = str(self.textEdit.toPlainText())
        name_s = int(self.lineEdit_20.text())
        content_f = str(self.lineEdit_12.text())
        content_cs = str(self.lineEdit_13.text())
        content_cs = content_cs.split(',')
        content_c = list()
        for i in range(len(content_cs)):
            content_c.append(int(content_cs[i]))
        content_c = tuple(content_c)
        content_s = int(self.lineEdit_19.text())
        uqid_f = str(self.lineEdit_18.text())
        uqid_cs = str(self.lineEdit_15.text())
        uqid_cs = uqid_cs.split(',')
        uqid_c = list()
        for i in range(len(uqid_cs)):
            uqid_c.append(int(uqid_cs[i]))
        uqid_c = tuple(uqid_c)
        uqid_s = int(self.lineEdit_14.text())
        temp_location = str(self.lineEdit_16.text())
        save_location = str(self.lineEdit_17.text())

        #Reading Data from spreadsheet into List
        final = service.spreadsheets().values().get(
            spreadsheetId=fspreadsheet_id,
            range='Sheet1',
            majorDimension='ROWS').execute()
        final = final['values']

        count = len(final)
        content = content.split(',')
        #Creating new folder on Google Drive
        drivename = 'Certificates ' + workshop
        file_metadata = {
            'name': drivename,
            'mimeType': 'application/vnd.google-apps.folder'
        }
        service1.files().create(body=file_metadata).execute()
        #folderid = input('Enter folder ID')
        text, result = QtWidgets.QInputDialog.getText(
            self, 'Folder ID', 'Enter the folder ID created in Google Drive')
        if result == True:
            folderid = text


#Generating Certificates with Name,Unique ID,etc. using PIL
        for i in range(1, count):
            name = final[i][0]
            uqid = final[i][3]
            img = Image.open(
                temp_location)  #Opening the img from user entered location
            draw = ImageDraw.Draw(img)
            W, H = img.size

            font = ImageFont.truetype(name_f, name_s)
            w, h = draw.textsize(name, font)
            location = ((W - w) / 2, ycoord)
            draw.text(location, name, fill=name_c, font=font)
            adjust = 0
            for i in range(len(content)):
                font2 = ImageFont.truetype(content_f, content_s)

                #Making adjustments and setting coordinates for the text to be added on image
                w1, h1 = draw.textsize(content[i], font2)
                location2 = ((W - w1) / 2, ycoord + 150 + adjust)
                draw.text(location2, content[i], fill=content_c, font=font2)
                adjust += 40

            font3 = ImageFont.truetype(uqid_f, uqid_s)

            w2, h2 = draw.textsize(uqid, font3)
            location3 = (150, 220)
            draw.text(location3, uqid, fill=uqid_c, font=font3)

            img = img.convert('RGB')
            img.save(save_location + '/' + name +
                     '.jpg')  #Saving the image locally on laptop
            #Uploading the image on Google Drive in the folder created earlier
            uploadname = name + '.jpg'
            mimetype2 = 'image/jpeg'
            file2_metadata = {'name': uploadname, 'parents': [folderid]}
            media = MediaFileUpload(save_location + '/' + name + '.jpg',
                                    mimetype=mimetype2)
            service1.files().create(body=file2_metadata,
                                    media_body=media,
                                    fields='id').execute()

        message3 = QtWidgets.QMessageBox.about(
            self, 'Info', 'All Certificates have been generated and uploaded')