Skip to main content
Tweeted twitter.com/StackCodeReview/status/1021953280308662279
deleted 20 characters in body; edited tags; edited title
Source Link
200_success
  • 145.7k
  • 22
  • 191
  • 481

Python, cleaning Cleaning up date strings to return as strings in Python

Please comment.

Python, cleaning up date strings to return as strings

Please comment.

Cleaning up date strings in Python

typo
Source Link
RolfBly
  • 897
  • 1
  • 10
  • 23
http://baseURL/name:Gupta,Anil%dateAnil&date:1956
http://baseURL/name:Gupta,Anil%date:1956
http://baseURL/name:Gupta,Anil&date:1956
Clarified a design choice
Source Link
RolfBly
  • 897
  • 1
  • 10
  • 23

I think my best bet is not to convert to type datetime, but to try to match strings.

EDIT: because this way I can let the API do more work.

http://baseURL/name:Gupta,Anil%date:1956

Without the date, I get all Anil Gupta's. With it, I get all Anil Gupta's with either born year (most likely), death year, of year of activity 1956. All in all, this is MUCH less work than writing dateconverters for fields that are empty in 90% of the cases. In general, name + exact date of birth is a pretty unique identifier.

So I wrote this dateclean.py (Python 3.7):

I think my best bet is not to convert to type datetime, but to try to match strings. So I wrote this dateclean.py (Python 3.7):

I think my best bet is not to convert to type datetime, but to try to match strings.

EDIT: because this way I can let the API do more work.

http://baseURL/name:Gupta,Anil%date:1956

Without the date, I get all Anil Gupta's. With it, I get all Anil Gupta's with either born year (most likely), death year, of year of activity 1956. All in all, this is MUCH less work than writing dateconverters for fields that are empty in 90% of the cases. In general, name + exact date of birth is a pretty unique identifier.

So I wrote this dateclean.py (Python 3.7):

added 3 characters in body
Source Link
Daniel
  • 4.6k
  • 2
  • 18
  • 40
Loading
Source Link
RolfBly
  • 897
  • 1
  • 10
  • 23
Loading