Intro to Spreadsheets

Data Generation

Using Faker.js to generate a large collection of names we can analyze. To begin, we need to come up with an ordered list of streets that seem reasonable that we’d sell to:

__ = require('/usr/local/lib/node_modules/underscore');
faker = require('/home/howard/Work/faker.js');

address = (streetname) -> __.random(3300, 3900) + " " + streetname

streets = __.flatten( __(10).times( (j) ->
    name = faker.address.streetName() + " " + faker.address.streetSuffix()
    buyers = __.random(5, 20)
    __(buyers).times((i) -> address(name))
))

console.log(streets)
var __ = require('/usr/local/lib/node_modules/underscore');
var faker = require('/home/howard/Work/faker.js');

function address(streetname) {
    return __.random(3300, 3900) + " " + streetname;
}

var streets = __.flatten( __.times(10, function(j) {
    var name = faker.address.streetName() + " " + "St."; // faker.address.streetSuffix();
    var buyers = __.random(5, 20);
    return __.sortBy( __.times(buyers, function(i) {
        return address(name);
    }));
}));

function newPerson(address) {
    return [ faker.name.firstName(),
             faker.name.lastName(),
             address,
             "503-" + __.random(100,999) + "-" + __.random(1000,9999)
           ];
}

__.each( streets, function(s) {
    console.log( newPerson(s).join() );
});
for(r = 0; r < rows; r++) {
    var row = [];
    for(c = 0; c < cols; c++) {
        row[c] = 0;
    }

    row[ Math.floor(Math.random() * cols) ] = 1;
    for(t = 0; t < 2; t++) {
        for(c = 0; c < cols; c++) {
            if (Math.random() * 100 > 95) {
                row[c]++;
            }
        }
    }
    console.log( row.join() );
}