-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathgenerate_actions_dt.py
36 lines (29 loc) · 1.13 KB
/
generate_actions_dt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# This file was made for the class:
# SQL for Marekters: Dominate data analytics, data science, and big data
#
# It can be found at:
# https://udemy.com/sql-for-marketers-data-analytics-data-science-big-data
import sys
import random
# from datetime import datetime
NAMES = ['Alice', 'Bob', 'Carol', 'Dave', 'Emily', 'Frank', 'Gina']
PRODUCTS = ['Apple', 'Orange', 'Banana', 'Blueberry', 'Raspberry', 'Apricot', 'Cherry', 'Grape', 'Mango']
def generate(N, fn):
with open(fn, 'w') as f:
i = 0
while i < N:
name = random.choice(NAMES)
product = random.choice(PRODUCTS)
price = str(0.99)
year = random.choice(['2014', '2015'])
month = str(random.choice(range(12)) + 1)
if len(month) == 1:
month = "0" + month
day = str(random.choice(range(28)) + 1)
if len(day) == 1:
day = "0" + day
dt = "%s-%s-%s 00:00:00" % (year, month, day)
f.write("%s,%s,%s,%s,%s\n" % (name, product, 'purchase', price, dt))
i += 1
if __name__ == '__main__':
generate(1000000, 'dt_actions.csv')