[Python] Reading date from .xlsx file returns 5 digit timestamp, what is this?

Discussão em 'Python' iniciado por Stack, Março 2, 2025.

  1. Stack

    Stack Membro Participativo

    My script converts a .xlsx file into many .csv files (one .csv per sheet).

    Here is the code:

    wb = xlrd.open_workbook(filepath)

    for i in range(0, wb.nsheets):
    sh = wb.sheet_by_index(i)
    sheet_name = sh.name
    sheet_name = sheet_name.replace(" ", "_");
    fp = open(sheet_name+'.csv', 'at', encoding='utf8')
    wr = csv.writer(fp, quoting=csv.QUOTE_ALL)

    for row_num in range(sh.nrows):
    wr.writerow(sh.row_values(row_num))

    fp.close()


    Full code here: https://github.com/andreipdev/xlsx_to_csv

    This works well, except that I have a field that is a date, in excel it shows for example: 01/01/2009

    But the final csv, contains a number that is 39814. What is this please, what can I do with it? 01/02/2009 is 39815.

    Is it a number I can use to find the unix timestamp? Or is it an issue and I should change my script? I would feel safer if it would just return the string "01/01/2009".

    Continue reading...

Compartilhe esta Página