Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError time data does not match format #29

Open
Kumaezenjae opened this issue Jul 12, 2024 · 0 comments
Open

ValueError time data does not match format #29

Kumaezenjae opened this issue Jul 12, 2024 · 0 comments

Comments

@Kumaezenjae
Copy link

Observed bug and provided quick-fix here:

In file:
...\Python\Python312\Lib\site-packages\google_flight_analysis\flight.py

Change Line 116 from:
self._times += [datetime.strptime(self._date + " " + arg, date_format) + delta]
To instead be:
self._times += [datetime.strptime(self._date + " " + arg.replace(' AM','AM').replace(' PM','PM'), date_format) + delta]


Traceback (most recent call last):
File "", line 1, in
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib\site-packages\google_flight_analysis\scrape.py", line 39, in ScrapeObjects
debug = [obj._scrape_data(driver) for obj in tqdm(objs, desc="Scraping Objects")]
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib\site-packages\google_flight_analysis\scrape.py", line 377, in _scrape_data
results = [self._get_results(url, self._date[i], driver) for i, url in enumerate(self._url)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib\site-packages\google_flight_analysis\scrape.py", line 405, in _get_results
flights = _Scrape._clean_results(results, date)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib\site-packages\google_flight_analysis\scrape.py", line 424, in _clean_results
flights = [Flight(date, res3[matches[i]:matches[i+1]]) for i in range(len(matches)-1)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib\site-packages\google_flight_analysis\flight.py", line 29, in init
self._parse_args(*args)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib\site-packages\google_flight_analysis\flight.py", line 157, in _parse_args
self._classify_arg(arg)
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib\site-packages\google_flight_analysis\flight.py", line 116, in _classify_arg
self._times += [datetime.strptime(self._date.replace(' AM','AM').replace(' PM','PM') + " " + arg, date_format) + delta]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib_strptime.py", line 554, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\myuser\AppData\Local\Programs\Python\Python312\Lib_strptime.py", line 333, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '2024-07-23 5:10 AM' does not match format '%Y-%m-%d %I:%M%p'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant