how to find a particular date when there are many dates - python

I have a data which I collected by web-scraping. In my scraping data, there are the different date in the different format, I need to find a particular date from data so I made a regular expression for python that can find a date from any format.
The regular expression I made is:
(?:\w+\/\w+\/\w+|\w+\-\w+\-\w+|\d+\s+\w+\s+\d+)
I got the date in correct syntax but the main task is to retrieve a particular date.I have a string in which i used a regular expression like
The starting date of application is 21/10/2018 and end date is
30/10/2018. The application was issued on 10 November 2018
I want to retrieve start date, issued date and end date. Can Somebody help me..

Related

How can I organize a list of assignments in a calendar interface using python?

I am creating the backend of a web application with Python and FastAPI. The application has the following database:
(To manipulate the database I am using Tortoise-ORM).
An application interface should look something like this:
In other words, for each month of the year I must show a kind of "calendar" where the assignments corresponding to each job are grouped by project. (I only have to take care of the backend)
So, my initial idea is to obtain all the assignments corresponding to a specific month (first problem, the assignments have a start date and an end date, so they must be the ones that have days within that range) and group them by project, for job... but my big problem is that I need to have them per day since I have to feed the calendar for each day.
How could I implement it?

Any way to include variable date in API URL?

I'm pretty new to python, I have been able to connect to an API and get the data I want. However I notice that the date field has be hardcoded in the URL.
https://api.eia.gov/v2/electricity/rto/fuel-type-data/data?api_key=XXXX&start=2022-05-18T00
I plan to run the script daily and I am only interested in the past week of data. Is there a way to code this so I don't need to change the date manually everyday?
Thanks!

Bloomberg API how to get only the latest quote to a given time specified by the user in Python?

I need to query from the BBG API the nearest quote to 14:00 o'clock for a number of FX currency pairs. I read the developers guide and I can see that reference data request provides you with the latest quote available for a currency however if I run the request at 14.15 it will give me the nearest quote to that time not 14.00. Historical and intraday data output too many values as I need only the latest quote to a given time.
Would you be able to advise me if there is a type of request which will give me what I am looking for.
Further to previous suggestions, you can start subscription to //blp/mktdata service before 14:00 for each instrument to receive stream of real-time ticks. Cache the last tick, when hitting 14:00 mark the cache as pre-14:00, then mark the first tick after as post:14, select the nearest to 14:00 from both.

Exchanging Information between HTML Form and SQL Database

Happy Easter to y'all!
So my problem is essentially using SQL timestamp is causing me some issues. I have a Travel Booking website with a database made in PHPmyadmin and as mentioned two timestamp columns (one for departure time and one for arrival.) If there are times currently there for the journey they will be displayed, if not a tick box to set the current time as the timestamp, this i'm fine with.
I don't know what html form element to use to display the entirety of the SQL timestamp, both the date and time section in the html form (or how to validate any of it xD) I have tried splitting the timestamp and displaying it in both a date and time field but had no luck and was told to stick to the timestamp by my group members. Cheers
Solved the problem with some troubleshooting. The formatting difference between datetime-local and timestamp can be solved with some simple regex.
VariableName = re.sub(r"\s+", 'T', VariableName)
Swaps any whitespace characters with a T.
This is because datetime-local likes to concatenates the date and time together using a capital T. If we simulate this using the regex above we can convert the timestamp into a readable format.

Looking to retrieve Tweets from a certain time via Twitter api but my script returns 0 tweets

So I'm trying to get tweets from November 13 - November 15 that mention the word "paris" for a text-analysis project I'm working on.
When I try this code:
p = {"q":"paris", "since":"2015-11-13", "until":"2015-11-15", "lang":"en", "count":100}
paris = requests.get("https://api.twitter.com/1.1/search/tweets.json",params=p,auth=oauth)
I get 0 statuses from paris.json().
Is there a better way to do what I'm trying to do? And if possible I'd like to know how to do a search that looks "paris" or "breaking" or "terrorist" or "bombing" etc....
Thanks
Two issues with what you're trying:
since is not a valid search parameter. There's since_id which requires the ID of a tweet to start from; not a date.
until is correct and requires a date which you have in the correct format but it has this restriction:
Keep in mind that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week.
Some things for you to check if you aren't sure you are authenticating correctly:
How have you generated your auth token? Hopefully you're using "Application-only authentication".
You're already using the 'requests' package so you could use the OAuth 1 workflow from that.
Look at the response headers with paris.headers to make sure you aren't getting some other error which is being ignored.

Categories