Skip to content

Instantly share code, notes, and snippets.

@nyasba
Last active October 9, 2016 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyasba/b7ec905a377bee8fb91586cdecfc353f to your computer and use it in GitHub Desktop.
Save nyasba/b7ec905a377bee8fb91586cdecfc353f to your computer and use it in GitHub Desktop.
Redshift投入サンプルデータ作成用スクリプト
# -*- 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