import pandas as pd
import numpy as np

shapes = pd.read_csv("./shapes.txt")
del shapes["shape_dist_traveled"]

# grabbing only the bits we need/understand
stops = pd.read_csv("./stops.txt")[["stop_id", "stop_lat", "stop_lon"]]

stop_times = pd.read_csv("stop_times.txt")[["trip_id", "stop_id", "stop_sequence"]]

trips = pd.read_csv("trips.txt")[
    ["route_id", "service_id", "trip_id", "direction_id", "shape_id"]
]

# remove trips corresponding to the number of laps in a day
trips = trips[trips["trip_id"].map(lambda a: a[-3] != "T" or a[-3:] == "T01")]

routes = pd.read_csv("./routes.txt")[
    [
        "route_id",
        "route_long_name",
        "route_color",
        "route_text_color",
    ]
]

# these + stop_times are needed for schedule info
calendar = pd.read_csv("calendar.txt")
calendar_dates = pd.read_csv("calendar_dates.txt")


# This dead ends
# these are what's needed to make route json files
#route_stop_join = trips[["trip_id", "route_id", "direction_id"]][
#    (trips["service_id"] == "mtwtf") | (trips["service_id"] == "mtwtf_BU")
#].merge(stop_times[["trip_id", "stop_id", "stop_sequence"]], on="trip_id", how="inner")[
#    ["route_id", "stop_id", "stop_sequence", "direction_id"]
#]
#
#route_shape_join = trips[["route_id", "shape_id", "direction_id"]][
#    (trips["service_id"] == "mtwtf") | (trips["service_id"] == "mtwtf_BU")
#].merge(shapes, on="shape_id", how="inner")
