Skip to content

Instantly share code, notes, and snippets.

View paulgambill's full-sized avatar

Paul Gambill paulgambill

View GitHub Profile
@paulgambill
paulgambill / gist:7146202
Created October 24, 2013 22:24
This Ruby script parses the dataset from https://catalog.data.gov/dataset/baby-names-from-social-security-card-applications-data-by-state-and-district-of- to find the top name for each sex/year/state permutation. The result is a .csv with a row for each year/sex/top name combination. Be sure to replace the path on line 7 with your local path.
require 'csv'
year = 1910
CSV.open("stateNamesParsed.csv", "ab") do |csv|
Dir.glob('PATH/*.TXT') do |file|
next if file == '.' or file == '..'
File.open(file).readlines.each do |line|
array = line.split(',')
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();