[Python] SAS date9 format to python datetime

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I've got a CSV formatted with SAS's date9. output. But dateutil.parser.parse doesn't recognise it and nor does pandas.to_datetime (also a question, does to_datetime use dateutil.parser?).

    They throw:

    File "C:\redacted\dateutil\parser.py", line 559, in parse
    raise ValueError("Unknown string format")

    ValueError: Unknown string format


    The format looks like this:

    0 12FEB1993
    1 12FEB1993
    ...
    16 16NOV1972
    17 01SEP2001
    18 06JUL2000
    19 01FEB2014


    With everything that matters in the second column. Is there any library that can solve this or do I have to roll my own? And if it is the latter, how?

    Continue reading...

Compartilhe esta Página