dsriggs1 / Baseball_Project

Predicting fantasy baseball player performance
0 stars 0 forks source link

Create shell script to run get_weather #8

Open dsriggs1 opened 1 year ago

dsriggs1 commented 1 year ago

On the web_scraping branch create a shell script that imports this file: https://github.com/dsriggs1/Baseball_Project/blob/web_scraping/Code/Production/create_model_ready.py

And creates an instance of the class "Database" and calls the method get_weather. Pass an argument city="Charlotte" into get_weather and print out the df. Try this as a first pass:

!/usr/bin/env bash

Import the create_model_ready.py module

python -c "import create_model_ready"

Run the Python code

python -c " from create_model_ready import Database, WebScrape

db = Database('root', 'abcdefgh1!', 'localhost', 'retrosheet') web_scrape = WebScrape('root', 'abcdefgh1!', 'localhost', 'retrosheet') df = web_scrape.get_weather('Charlotte') " You won't have access to the database, but it shouldn't matter for the get_weather method.

Stewartam1989-git commented 1 year ago

The first thing is to install all the packages in Linux:

sudo pip install numpy sudo pip install pandas sudo pip install sqlalchemy sudo pip install bs4 sudo pip install datetime

Then try to run the script:

python3 create_model_ready.py

python3 -c " import create_model_ready from create_model_ready import Database, WebScrape

db = Database('root', 'abcdefgh1!', 'localhost', 'retrosheet') web_scrape = WebScrape('root', 'abcdefgh1!', 'localhost', 'retrosheet') df = web_scrape.get_weather('Charlotte') print(df) "

Stewartam1989-git commented 1 year ago

Put the following into a shell script:

{ python3 -c " import create_model_ready from create_model_ready import Database, WebScrape

db = Database('root', 'abcdefgh1!', 'localhost', 'retrosheet') web_scrape = WebScrape('root', 'abcdefgh1!', 'localhost', 'retrosheet') df = web_scrape.get_weather('Charlotte') print(df) " }

Convert the shell script to a unix file:

dos2unix web_scrape.sh

Then run the file:

bash web_scrape.sh