Skip to content

Instantly share code, notes, and snippets.

@ktraff
Last active December 21, 2016 20:08
Show Gist options
  • Save ktraff/100f35449e0aa4e0521b to your computer and use it in GitHub Desktop.
Save ktraff/100f35449e0aa4e0521b to your computer and use it in GitHub Desktop.
Generates pseudo-random timeseries data and saves to a csv file.
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