--- /dev/null
+{
+ "metadata": {
+ "name": "make_animals"
+ },
+ "nbformat": 2,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "animals = ('Moose', 'Elk', 'Fox', 'Owl', 'Wolf', 'Muskox', 'Ptarmigan', 'Grizzly', 'Wolverine')"
+ ],
+ "language": "python",
+ "outputs": [],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "import datetime as dt",
+ "import random"
+ ],
+ "language": "python",
+ "outputs": [],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "def make_animals(filename, lines=100):",
+ " date = dt.date(2011, 4, 22)",
+ " one_day = dt.timedelta(days=1)",
+ "",
+ " f = open(filename, 'w')",
+ "",
+ " f.write('Date,Time,Animal,Count\\n')",
+ " for _ in xrange(lines):",
+ " animal = random.choice(animals)",
+ " hour = random.randint(0, 23)",
+ " minute = random.randint(0, 59)",
+ " number = random.randint(1, 42)",
+ " ",
+ " date_str = '{}-{:02d}-{:02d}'.format(date.year, date.month, date.day)",
+ " ",
+ " time_str = '{:02d}:{:02d}'.format(hour, minute)",
+ " ",
+ " line = '{},{},{},{}\\n'.format(date_str, time_str, animal, number)",
+ " ",
+ " f.write(line)",
+ " ",
+ " if random.choice((True, False)):",
+ " date = date + one_day",
+ " ",
+ " f.close()"
+ ],
+ "language": "python",
+ "outputs": [],
+ "prompt_number": 31
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "def make_animals_unstruct(filename, lines=100):",
+ " date = dt.date(2011, 4, 22)",
+ " one_day = dt.timedelta(days=1)",
+ "",
+ " f = open(filename, 'w')",
+ "",
+ " for i in range(lines):",
+ " animal = random.choice(animals)",
+ " hour = random.randint(0, 23)",
+ " minute = random.randint(0, 59)",
+ " number = random.randint(1, 42)",
+ " ",
+ " date_str = '{}-{:02d}-{:02d}'.format(date.year, date.month, date.day)",
+ " ",
+ " time_str = '{:02d}:{:02d}'.format(hour, minute)",
+ " ",
+ " line = '{} {{\\nDate: {}\\nTime: {}\\nAnimal: {}\\nCount: {}\\n}}\\n\\n'.format(i, date_str, time_str, animal, number)",
+ " ",
+ " f.write(line)",
+ " ",
+ " if random.choice((True, False)):",
+ " date = date + one_day",
+ " ",
+ " f.close() "
+ ],
+ "language": "python",
+ "outputs": [],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "make_animals('sightings_tab_sm.csv', 5)",
+ "#make_animals_unstruct('sightings_recs_sm.txt', 3)"
+ ],
+ "language": "python",
+ "outputs": [],
+ "prompt_number": 33
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [
+ "make_animals('sightings_tab_lg.csv', 200)",
+ "make_animals_unstruct('sightings_recs_lg.txt', 200)"
+ ],
+ "language": "python",
+ "outputs": [],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "code",
+ "collapsed": true,
+ "input": [],
+ "language": "python",
+ "outputs": []
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file