I am trying to edit my python script so that it will pull data from a database daily. Currently my script asks for a manual (raw) input of the date in the format: YYY:MM:DD:HH:MM:SS. But what I really need is for the start time to be calculated based on the current date.
This is what my script looks like now:
from datetime import datetime, timedelta
from pandas import DataFrame
import pandas as pd
from io import StringIO
starttime_str = raw_input("enter time:") # example 2016:10:18:00:00:00
arr = starttime_str.split(':')
starttime = datetime(int(arr[0]), int(arr[1]), int(arr[2]), int(arr[3]), int(arr[4]), int(arr[5]))
But what I really need for the starttime_str
to be the computer's date. So perhaps I should write a function to find the date and then calculate the time stamp? I will update the cron entry so that the script runs daily & automatically. I know I should use something like pd.tslib.Timestamp.now()
but I don't need the whole string.