Questions tagged [dateparser]

dateparser provides modules to easily parse localized dates in almost any string formats commonly found on web pages.

46 questions
4
votes
3 answers

dateparser throws regex._regex_core.error

I am trying to run a very basic script: import dateparser dateparser.parse('12/12/12') but I keep getting the same error Traceback (most recent call last): File ".../app/test.py", line 3, in dateparser.parse('12/12/12') File…
user3714205
  • 83
  • 1
  • 1
  • 8
4
votes
2 answers

How to use dateparser to detect dates in strings?

I want to use dateparser to detect which cell contains a date. I have a broad range of different date formats: Fr, 21.02.2020 // 20.02.2020 // 21.02 // 21-02-2020 // January, 21 2020 // 21-Jan-2020 // 21/02/20 and I am sure there will still come a…
hux0
  • 207
  • 1
  • 4
  • 17
3
votes
1 answer

How to make dateparser parse date relative to a given day

I am using dateparser python's module to parse dates. How can I get dateparser to count not from the current date and time, but from the date I set, like today = datetime(2021, 1, 1)?
ferrum
  • 169
  • 1
  • 13
2
votes
0 answers

Know which parts a day contains

The dateparser library set missing parts of a date to today's values. Example: >>> import dateparser >>> dateparser.parse("2015") datetime.datetime(2015, 2, 14, 0, 0) How to know which parts a date really contains? (and thus which parts were set to…
robertspierre
  • 3,218
  • 2
  • 31
  • 46
2
votes
1 answer

Parsing dates from OCRed files using dateparser library

I want to extract dates from OCR images using the dateparser lib. import dateparser data = [] listOfPages = glob.glob(r"C:/Users/name/folder/test/*.tif") for entry in listOfPages: text1 = pytesseract.image_to_string( …
id345678
  • 97
  • 1
  • 3
  • 21
2
votes
1 answer

Using dateparser to get a range of dates

I was having a problem with dateparser when it is given a string such as "Dec. 3-4". I have an array of dates (without year) but I have no idea how I would split up that date to make it print out "12/3" and "12/4". My current output is "12/3" and…
2
votes
0 answers

Why does dateparser stop working in my Flask app when I set a TZ environment variable?

I have whittled a much-larger Flask app down to the essentials in order to try to figure out why dateparser (0.7.6 and also 1.0.0) is not working in Flask (Flask 1.1.2, Werkzeug 1.0.1) under Python 3.8.5 in Windows 10. run.py from mytest import app…
David White
  • 1,763
  • 2
  • 16
  • 27
2
votes
0 answers

How to determine whether dateparser.search.search_dates() returns dates, times, or datetimes

Trying to answer another question I stumbled over the following problem: dateparser.search.search_dates() returns a list of tuples, each tuple consisting of a text segment recognized as carrying date and/or time information, and the corresponding…
Walter Tross
  • 12,237
  • 2
  • 40
  • 64
2
votes
2 answers

Getting datetime format from String?

In Python there are multiple DateTime parser's which can parse a date string automatically without proving the datetime format. e.g. DateParser, DateUtils. However, There is no option in any of them where the format in which the date was parsed is…
user4428032
1
vote
1 answer

How to modify format and form of presenting date column in Python Pandas?

I have Python Pandas DataFrame like below: col1 ---- 01.05.2019 02.11.2022 11.08.2001 And col1 is in "object" format. I need to read this Data Frame from csv and in "read_csv" function modify: format of this column from "object" to "date" form of…
dingaro
  • 2,156
  • 9
  • 29
1
vote
0 answers

dataparser with month+year, without day

I want to parse dates of different formats and dataparser seems to be the best option to handle most of weird cases. However, I'm having problem with dates without a day, e.g. "04/2022". I'd like such a string to be extracted as month=4, year=2022,…
Malgorzata
  • 11
  • 1
1
vote
1 answer

Date Entity Parsing Incorrect Year for Incomplete Dates

I have a dataset (df_test) containing of several news articles (Text_4). Using SpaCy, I've extracted the 'DATE' entities. For those I want to see whether they are in the future or in the past (to identify news articles that reference future events…
AlexanderP
  • 126
  • 6
1
vote
1 answer

Efficiently processing dates from strings of inconsistent date formatting in pandas dataframes?

Simplified huge df with date column of inconsistent string formatting containing errors: df_length = 10000 df = pd.DataFrame({ "to_ignore": np.random.randint(1, 500, df_length), "date": np.random.choice(["11 Nov 2018", "Feb 2019",…
1
vote
1 answer

Exclude relative dates when parsing text with the dateparser.search module

Trying to get search_dates from dateparser.search ignore relative dates like "tomorrow", "next week", "more", etc. Currently, here's the behavior I'm getting: from dateparser.search import search_dates In: search_dates("more",…
1
vote
2 answers

How can I parse a string to extract a date and assign 2021 as the year where appropriate in Python 3.8?

I'm using dateparser to parse strings and return a date value to compare against an extraction date then return an integer value as the difference between the two. In some cases, the parsed date is a range, in which case I average the two ends of…
GiltLorn
  • 11
  • 2
1
2 3 4