Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created January 31, 2017 08:27
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 ivancorrales/c65f20cb513848334af83effff70da79 to your computer and use it in GitHub Desktop.
Save ivancorrales/c65f20cb513848334af83effff70da79 to your computer and use it in GitHub Desktop.
from utils import Bullying
import csv
NUM_RECORDS = 10000000
INPUT_DATA_FILE_PATH= './../data/input_data.csv'
def generate_array(iterations = NUM_RECORDS):
array = [None] * NUM_RECORDS
for r in range(iterations):
bullying = Bullying()
bullying \
.age() \
.genre() \
.short() \
.wear_braces() \
.wear_glasses() \
.less_popular() \
.different_race() \
.low_socioeconomic_status() \
.gay_or_lesbian() \
.have_disability() \
.overweight() \
.shy() \
.affected()
array[r] = bullying.__dict__
return array
def main():
bullying_array = generate_array()
with open(INPUT_DATA_FILE_PATH, 'w') as csvfile:
writer = csv.writer(csvfile, delimiter=',')
writer.writerow(["Range","Is short","shy","Wear braces","Wear glasses","Is less popular", "Different race", "Low socioeconomic status","Gay or lesbian",
"Have disability", "Overweight", "Genre", "Age", "Suffer from utils"])
writer.writerows(
(
bullying['range'],
bullying['short'],
bullying['shy'],
bullying['wear_braces'],
bullying['wear_glasses'],
bullying['less_popular'],
bullying['different_race'],
bullying['low_socioeconomic_status'],
bullying['gay_or_lesbian'],
bullying['have_disability'],
bullying['overweight'],
bullying['genre'],
bullying['age'],
bullying['affected'],
)
for bullying in bullying_array
)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment