Skip to content

Commit

Permalink
changes to DB code
Browse files Browse the repository at this point in the history
  • Loading branch information
kcelebi committed May 8, 2023
1 parent 5b2136a commit 47765b4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/google_flight_analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
Written by Kaya Celebi, March 2022
****************************************************************************************************************************************************************/'''

from typing import overload
import numpy as np
import pandas as pd
from tqdm import tqdm
import json
import os
from tqdm import tqdm, trange
from flight import Flight


2 changes: 1 addition & 1 deletion src/google_flight_analysis/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def cache(self, obj, db):
recent_access = file.readline()
if recent_access != current_access:
df_old = pd.read_csv(fname, index_col = 'Unnamed: 0')
df = pd.concat([df_old, df])
df = pd.concat([df_old, df], ignore_index = True)
else:
return # Data already in csv, redundant

Expand Down
6 changes: 3 additions & 3 deletions src/google_flight_analysis/flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ def _classify_arg(self, arg):
# or multiple stops
self._stops = arg
elif len(arg) > 0 and arg != 'Separate tickets booked together' and arg != 'Change of airport':
#val = arg.split(',')
#val = [elem[] if 'Operate' in elem for elem in val]
self._airline = arg
val = arg.split(',')
val = [elem.split('Operated')[0] for elem in val]
self._airline = ','.join(val)
else:
self._trash += [arg]
# airline and other stuff idk
Expand Down
3 changes: 1 addition & 2 deletions src/google_flight_analysis/scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def _scrape_data(self):
if self._date_return is not None:
return_result = self._get_results(self._make_url(self._date_return, leave = False), driver)
driver.quit()
return pd.concat([leave_result, return_result])
return pd.concat([leave_result, return_result], ignore_index = True)

driver.quit()
return leave_result
Expand Down Expand Up @@ -172,7 +172,6 @@ def _get_results(self, url, driver):

def _clean_results(self, result):
res2 = [x.encode("ascii", "ignore").decode().strip() for x in result]
#res2 = [x[0:-2] if len(x) > 2 and x[-2] == '+' else x for x in res2 ]

start = res2.index("Sort by:")+1
mid_start = res2.index("Price insights")
Expand Down

0 comments on commit 47765b4

Please sign in to comment.