Last active
October 9, 2016 03:04
-
-
Save nyasba/b7ec905a377bee8fb91586cdecfc353f to your computer and use it in GitHub Desktop.
Redshift投入サンプルデータ作成用スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from datetime import datetime | |
from datetime import timedelta | |
import random | |
import csv | |
def createOneDayFile(targetdate): | |
with open("sample" + targetdate.strftime("%Y%m%d") + ".csv", 'w') as f : | |
writer = csv.writer(f, lineterminator = '\n') | |
writer.writerow( ['created_at','max','min'] ) | |
for i in range(24*60*60) : | |
list = [] | |
list.append(targetdate + timedelta(seconds = i)) | |
r1 = random.randint(0, 1000) | |
r2 = random.randint(0, 1000) | |
list.append( max(r1, r2) ) | |
list.append( min(r1, r2) ) | |
writer.writerow(list) | |
if __name__ == "__main__": | |
d = datetime.strptime( "20161001", "%Y%m%d") | |
for day in range(30): | |
tmp = d + timedelta(days = day) | |
createOneDayFile(tmp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment