Skip to main content

Extracts timestamp from a given text/string

Project description

datetime_extractor

The main intent of this project is to extract mostly all possible timestamps from a given string where date and time written together. It extracts timestaamps in a string format. Later one can convert extracted timestamp to python timestamp using pandas datetime package.

How to install the package

	pip install datetime-extractor

Example1

  from datetime_extractor import DateTimeExtractor

  import pandas as pd
  import re

  samplestring = 'scala> val xorder= new order(1,"2016-02-22 00:00:00.00",100,"COMPLETED")'

  DateTimeExtractor(samplestring)

  Out: ['2016-02-22 00:00:00.00']

Example2

Suppose if one has a dataframe with text column where timestamps written, the above function can be used to create a new column with extracted timestamp strings. One can use below command in this case

  data = pd.read_csv('sampledata.csv')
  data['textcolumn'] = data['textcolumn'].fillna('')

  data['ExtractedTimestamp'] = data['textcolumn'].apply(lambda x: DateTimeExtractor(str(x)))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datetime_extractor-0.5.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file datetime_extractor-0.5.tar.gz.

File metadata

  • Download URL: datetime_extractor-0.5.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for datetime_extractor-0.5.tar.gz
Algorithm Hash digest
SHA256 9706118af2c423dc3a23875651fe910a12fedb3fb1f31e44d6177be3e33a6234
MD5 ade9dee554a4a44ecbdca1112b888eef
BLAKE2b-256 b9666b28056bdb706794db2c1546659d0417d18248b0efaf9b2c10e59efb678e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page