'openpyxl convert scraped data in time format

I would like to convert the data scraping from an internet site, regarding the time, the data is extracted like this (for example 9:15) and inserted into the cell, I would like at the bottom of the column to make the total of the hours, the problem I would like python to convert it to numerical format so that I can add it up. any idea?

def excel():
    # Writing on a EXCEL FILE
    filename = f"Monatsplan {userfinder} {month} {year}.xlsx"
    try:
        wb = load_workbook(filename)
        ws = wb.worksheets[0]  # select first worksheet
    except FileNotFoundError:
        headers_row = [
            "Datum",
            "Tour",
            "Funktion",
            "Von",
            "Bis",
            "Schichtdauer",
            "Bezahlte Zeit",
        ]
        wb = Workbook()
        ws = wb.active
        ws.append(headers_row)

    wb.save(filename)
    ws.append(
        [
            datumcleaned[:10],
            tagesinfo,
            "",
            "",
            "",
            "",
            "",
        ]
    )
    wb.save(filename)
    wb.close()

excel()


Solution 1:[1]

You should split the data you scrapped.

time_scrapped = '9:15' 
time_split = time_scrapped.split(":")  
hours = int(time_split[0])
minutes = int(time_split[1])

Then you can place it in separate columns and create formula at the bottom of the column.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alvin Cruz