[Python] The program stops when it encounters a time jump

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

    I wrote a program for filter in my pacman log for the package changes after 21:00 hrs but not even reads all the log file.

    import re

    def filter(filename, date, outFilename):
    with open(filename, 'r') as infile, open(outFilename, 'w') as outfile:
    for line in infile:
    match = re.match(r'^\[(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})\+\d{4}\]', line)
    if match:
    current_time = match.group(1)
    print(current_time)
    if current_time >= date:
    outfile.write(line)

    filter('/var/log/pacman.log', '2025-01-02T21:00:00', 'filteredRegister.txt')


    the line 'print(current_time)' is for debug. the program stops after 2024-12-24T20:29:34, i think because the hour in the log's hour changes suddenlu to 2024-12-24T15:54:02 for a change in the timezone. Anyone can help me? PD: forgive my horrible english please.

    Continue reading...

Compartilhe esta Página