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

Export CSV file with google link based on Beam Travel times #2438

Merged
merged 6 commits into from
Mar 26, 2020

Conversation

carloscaldas
Copy link
Collaborator

@carloscaldas carloscaldas commented Mar 22, 2020

Issue: #2426

Running the script (python v3):

python generate_rides_with_google_maps.py \
  --inputFile=/path-to-the-file/0.personal.CarRideStats.csv.gz \
  --sampleSize=10 \
  --sampleSeed=200 \
  --maxDistance=4450 \
  --departureTimeRange=[25246,25248]
  --areaBoundBox=[(10,11.1),(12,14)]

will generate the file
/path-to-the-file/0.personal.CarRideStats.output.csv

python generate_rides_with_google_maps.py \
  --inputFile="https://beam-outputs.s3.amazonaws.com/output/sf-light/austin-light-100k__2020-03-02_20-06-35_cnx/ITERS/it.9/9.CarRideStats.csv.gz" \
  --sampleSize=10 \
  --sampleSeed=200 \
  --maxDistance=4450 \
  --departureTimeRange=[25246,25248]
  --areaBoundBox=[(10,11.1),(12,14)]

will generate the file
/path-to-the-python_script/output/sf-light/austin-light-100k__2020-03-02_20-06-35_cnx/ITERS/it.9/9.CarRideStats.output.csv


This change is Reviewable

@carloscaldas carloscaldas self-assigned this Mar 22, 2020
@carloscaldas carloscaldas changed the title Export CSV file with google link based on personal.CarRideStats.csv.g… Export CSV file with google link based on Beam Travel times Mar 22, 2020
@JustinPihony
Copy link
Collaborator

test!

@carloscaldas carloscaldas requested a review from REASY March 22, 2020 23:52
__author__ = "Carlos Caldas"


def main(args):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the verison of Python? Is it 2 or 3? Anyway, can you use https://docs.python.org/2/library/argparse.html to parse arguments instead of doing a lot of manual work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is Python 3. It is using getOpt. There is no lot of manual work, only default values definitions, so the arguments must be tested.


def convert_file(input_file_location, output_file_path, program_arguments):
df = read_csv_as_dataframe(input_file_location, program_arguments)
urls_list = generate_urls_as_list(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could do it in-place, e.g:

def google_link(start_x, start_y, end_x, end_y):
    return f"https://www.google.com/maps/dir/{start_y}%09{start_x}/{end_y}%09{end_x}"
df['google_link'] = df.apply(lambda x: google_link(x.start_x, x.start_y, x.end_x, x.end_y), axis=1)

@carloscaldas carloscaldas merged commit c2a7b76 into develop Mar 26, 2020
@carloscaldas carloscaldas deleted the ccaldas/#2426-addGoogleMapsToTravelTimes branch March 26, 2020 21:45
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

Successfully merging this pull request may close these issues.

4 participants