Skip to content

Instantly share code, notes, and snippets.

@RooseveltAdvisors
Created July 26, 2017 21:57
Show Gist options
  • Save RooseveltAdvisors/9857943b9667337191a0d03f9e19048d to your computer and use it in GitHub Desktop.
Save RooseveltAdvisors/9857943b9667337191a0d03f9e19048d to your computer and use it in GitHub Desktop.
jinja_template
import datetime
from jinja2 import Environment
start = datetime.datetime.strptime("2017-02-01", "%Y-%m-%d")
end = datetime.datetime.strptime("2017-07-24", "%Y-%m-%d")
date_generated = [start + datetime.timedelta(days=x) for x in range(0, (end-start).days+1)]
template = """spark-submit --master yarn --deploy-mode cluster --class com.xyz.XXXAPP s3://com.xyz/aa-1.5.11-all.jar --input-request-events s3://com.xyz/data/event_{{date_str}}/* --input-geofence-events s3://com.xyz/data2/event_/{{date_str}}/* --output s3://com.xyz/output/{{date_str}}"""
for date in date_generated:
ymd = date.strftime("%Y-%m-%d")
spark_cmd = Environment().from_string(template).render(date_str= ymd)
print(spark_cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment