コード例 #1
0
    def __get_trade_journal__(self):
        spreadsheets = ezsheets.listSpreadsheets()

        for key, value in spreadsheets.items():
            if value == self.title:
                return ezsheets.Spreadsheet(key)

        return self.__create_trade_journal__()
コード例 #2
0
def get_sheet_id(sheet_name):
    sheets = ezsheets.listSpreadsheets()
    if sheet_name not in sheets.values():
        raise Exception("This worksheet was not found in Google Drive")
    for sheet_id in sheets:
        if sheets[sheet_id] == sheet_name:
            logging.debug(sheet_id)
            return sheet_id
def get_spreadsheet(ss_name):
    # Make sure file exists
    if Path(ss_name).absolute().exists() == False:
        raise Exception(
            f"{ss_name} was not found in current working directory.")
    sheet_list = ezsheets.listSpreadsheets()
    # Strip extension off ss_name
    ss_no_ext = re.sub(r"(\..*)", "", ss_name)
    # Check if spreadsheet is already in Google Drive, if not upload it.
    if ss_no_ext not in sheet_list.values():
        ss = ezsheets.upload(f"{ss_name}")
        return ss
    # If so, get the key and open it.
    else:
        for key, value in sheet_list.items():
            if ss_no_ext == value:
                ss = ezsheets.Spreadsheet(key)
                return ss
コード例 #4
0
import ezsheets

print(ezsheets.listSpreadsheets())
コード例 #5
0
ファイル: eztest.py プロジェクト: JeffUsername/python-stuff
import ezsheets
ss = ezsheets.Spreadsheet('1QWeskhphyhEjIcdBziAvaFwkDni08AJaftSNnUQzkpE')
print(ss.title)
i = ezsheets.listSpreadsheets()
#print(i.values())
#print(i.items())
for item in i.items():
    print(item[1])
コード例 #6
0
import ezsheets
ss = ezsheets.Spreadsheet('1J-Jx6Ne2K_vqI9J2SO-TAXOFbxx_9tUjwnkPC22LjeU')
ss.title
ss.downloadAsExcel()  # Downloads the spreadsheet as an Excel file.
ss.downloadAsODS()  # Downloads the spreadsheet as an OpenOffice file.
ss.downloadAsCSV()  # Only downloads the first sheet as a CSV file.
ss.downloadAsTSV()  # Only downloads the first sheet as a TSV file.
ss.downloadAsPDF()  # Downloads the spreadsheet as a PDF.
ss.downloadAsHTML()  # Downloads the spreadsheet as a ZIP of HTML files.

ss.downloadAsExcel('a_different_filename.xlsx')

ss = ezsheets.createSpreadsheet('Delete me')  # Create the spreadsheet.
ezsheets.listSpreadsheets()  # Confirm that we've created a spreadsheet.
ss.delete()  # Delete the spreadsheet.
ezsheets.listSpreadsheets()
コード例 #7
0
#sets absolute path of file
file = os.path.join(userDirect, userInput)

#Matches naming of uploaded spreadsheet names in google sheets
ssName = userDirect + '\\' + (Path(file).stem)

#Tests if file can be uploaded
try:
    ezsheets.upload(file)
    print('Uploaded')
except:
    print('Invalid file format')

#Searches list of spreadsheets to match name with an ID
ssDict = ezsheets.listSpreadsheets()
for ids, names in ssDict.items():
    if names == ssName:
        ssId = ids

#Gets Spreadsheet object based off ID
ss = ezsheets.Spreadsheet(ssId)

#Asks users for what format to convert to - will default to whats typed in list if typed differently - ie 'excel' will equal 'Excel'
userFormat = pyip.inputChoice(
    ['Excel', 'ODS', 'CSV', 'TSV', 'PDF', 'HTML'],
    prompt='What format do you want to convert it to?\n')

#Formats based on what is typed in
if userFormat == 'Excel':
    ss.downloadAsExcel()