Best way to identify and extract dates from text Python?

前端 未结 7 858
孤城傲影
孤城傲影 2020-12-13 06:10

As part of a larger personal project I\'m working on, I\'m attempting to separate out inline dates from a variety of text sources.

For example, I have a large list o

7条回答
  •  一向
    一向 (楼主)
    2020-12-13 06:56

    I was also looking for a solution to this and couldn't find any, so a friend and I built a tool to do this. I thought I would come back and share incase others found it helpful.

    datefinder -- find and extract dates inside text

    Here's an example:

    import datefinder
    
    string_with_dates = '''
        Central design committee session Tuesday 10/22 6:30 pm
        Th 9/19 LAB: Serial encoding (Section 2.2)
        There will be another one on December 15th for those who are unable to make it today.
        Workbook 3 (Minimum Wage): due Wednesday 9/18 11:59pm
        He will be flying in Sept. 15th.
        We expect to deliver this between late 2021 and early 2022.
    '''
    
    matches = datefinder.find_dates(string_with_dates)
    for match in matches:
        print(match)
    

提交回复
热议问题