Last active
December 21, 2016 20:08
-
-
Save ktraff/100f35449e0aa4e0521b to your computer and use it in GitHub Desktop.
Generates pseudo-random timeseries data and saves to a csv file.
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
import random | |
import datetime | |
from datetime import timedelta | |
import csv | |
col_count = 5 | |
num_items = 1000 | |
cur_date = datetime.datetime.now() | |
with open('timeseries.csv', 'wb') as csvfile: | |
csvwriter = csv.writer(csvfile) | |
start_date = cur_date - timedelta(days=num_items) | |
csvwriter.writerow(['datetime'] + ['value' + str(i) for i in range(col_count)]) | |
for idx in range(num_items): | |
csvwriter.writerow([start_date] + [random.uniform(1, num_items) for i in range(1, col_count+1)]) | |
start_date += timedelta(days=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment