Esempio n. 1
0
def chunk_date_range(start_date: DateTime) -> Iterable[Mapping[str, any]]:
    """
    Returns a list of each day between the start date and now. Ignore weekends since exchanges don't run on weekends.
    The return value is a list of dicts {'date': date_string}.
    """
    days = []
    now = pendulum.now()
    while start_date < now:
        day_of_week = start_date.day_of_week
        if day_of_week != pendulum.SATURDAY & day_of_week != pendulum.SUNDAY:
            days.append({"date": start_date.to_date_string()})
        start_date = start_date.add(days=1)

    return days
Esempio n. 2
0
from pathlib import Path

siteId = '57775'

directory = Path('directory'+siteId)
if not directory.exists():
    directory.mkdir()

# if not logged in then this will only work for th last 14 days
testDate = DateTime(2019, 2, 1)

pvo = PVOutput()
pvo.login('username', 'password')

for idx in range(1,140):
    dateString = testDate.to_date_string()
    print('creating file ', dateString)
    try:
        data = pvo.getIntradayData(testDate, siteId)
    except NameError as e:
        print(e)
        print("missing data for " + dateString)
        testDate = testDate.add(days=1)
        continue

    with open(directory.as_posix() + f'/{dateString}.csv','w', newline='') as csvFile:
        dataFile = csv.writer(csvFile)
        dataFile.writerow(data.headers)
        dataFile.writerows(data.data)

    testDate = testDate.add(days=1)