0

I have the following error on a code sample:

raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: Fall Semester 2018 Printed: Caux, 15/01/2021

Following is the code sample:

import dateutil.parser as dparser

text = 'Fall Semester 2018 Printed: Caux, 15/01/2021'
date_value = dparser.parse(text)
print(date_value)
2
  • parser take date type format in a string form and then convert it. extract date and feed it to parser Commented Oct 17, 2022 at 12:20
  • I found the issue, just because there are two date types and '2018' and '15/01/2021', the dparser is failing to select one out of them @Mehmaam Commented Oct 18, 2022 at 7:04

1 Answer 1

1

dateutil.parser was not able to parse the string 'Fall Semester 2018 Printed: Caux, 15/01/2021' as a date.

You need to pass a string to it which it is able to parse.

Try splitting the string at the comma and passing only '15/01/2021'.

Alternatively, try setting the fuzzy or fuzzy_with_tokens parameters to True. This makes the parser more tolerant regarding the input format.

Sign up to request clarification or add additional context in comments.

2 Comments

okay, but if I have to pass '15/01/2021' specifically by splitting, than what is the use of dateutil.parser?
To convert the string '15/01/2021' to a datetime.datetime(2021, 1, 15).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.