Skip to content

Instantly share code, notes, and snippets.

@dnase
Last active August 29, 2015 13:59
Show Gist options
  • Save dnase/10748013 to your computer and use it in GitHub Desktop.
Save dnase/10748013 to your computer and use it in GitHub Desktop.
Fun with data parsing!
###########################################################
# How many ig'nant people have named their child some #
# version of "Khaleesi" (which is just an honorific, #
# similar to "queen" - her name is Daenerys Targaryen) #
###########################################################
#SPOILER ALERT: It's over 900.
#Commands:
$ wget http://www.ssa.gov/OACT/babynames/names.zip
$ unzip names.zip
$ cat yob* | grep -E "Kh?al[i|e]*s[i|e]" | awk -F"," '{ s+= $3 } END { print s }'
#Output:
$ wget http://www.ssa.gov/OACT/babynames/names.zip
--2014-04-15 13:01:21-- http://www.ssa.gov/OACT/babynames/names.zip
Resolving www.ssa.gov... 199.173.225.5, 137.200.4.16, 2001:1930:c01::aaaa, ...
Connecting to www.ssa.gov|199.173.225.5|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7494895 (7.1M) [application/zip]
Saving to: ‘names.zip’
100%[================================================================================================================================================================>] 7,494,895 15.3MB/s in 0.5s
2014-04-15 13:01:22 (15.3 MB/s) - ‘names.zip’ saved [7494895/7494895]
$ unzip names.zip
Archive: names.zip
inflating: yob1885.txt
inflating: yob1886.txt
inflating: yob1887.txt
inflating: yob1888.txt
inflating: yob1889.txt
inflating: yob1890.txt
inflating: yob1891.txt
inflating: yob1892.txt
inflating: yob1893.txt
inflating: yob1894.txt
inflating: yob1895.txt
inflating: yob1896.txt
inflating: yob1897.txt
inflating: yob1898.txt
inflating: yob1899.txt
inflating: yob1900.txt
inflating: yob1901.txt
inflating: yob1902.txt
inflating: yob1903.txt
inflating: yob1904.txt
inflating: yob1905.txt
inflating: yob1906.txt
inflating: yob1907.txt
inflating: yob1908.txt
inflating: yob1909.txt
inflating: yob1910.txt
inflating: yob1911.txt
inflating: yob1912.txt
inflating: yob1913.txt
inflating: yob1914.txt
inflating: yob1915.txt
inflating: yob1916.txt
inflating: yob1917.txt
inflating: yob1918.txt
inflating: yob1919.txt
inflating: yob1920.txt
inflating: yob1921.txt
inflating: yob1922.txt
inflating: yob1923.txt
inflating: yob1924.txt
inflating: yob1925.txt
inflating: yob1926.txt
inflating: yob1927.txt
inflating: yob1928.txt
inflating: yob1929.txt
inflating: yob1930.txt
inflating: yob1931.txt
inflating: yob1932.txt
inflating: yob1933.txt
inflating: yob1934.txt
inflating: yob1935.txt
inflating: yob1936.txt
inflating: yob1937.txt
inflating: yob1938.txt
inflating: yob1939.txt
inflating: yob1940.txt
inflating: yob1941.txt
inflating: yob1942.txt
inflating: yob1943.txt
inflating: yob1944.txt
inflating: yob1945.txt
inflating: yob1946.txt
inflating: yob1947.txt
inflating: yob1948.txt
inflating: yob1949.txt
inflating: yob1950.txt
inflating: yob1951.txt
inflating: yob1952.txt
inflating: yob1953.txt
inflating: yob1954.txt
inflating: yob1955.txt
inflating: yob1956.txt
inflating: yob1957.txt
inflating: yob1958.txt
inflating: yob1959.txt
inflating: yob1960.txt
inflating: yob1961.txt
inflating: yob1962.txt
inflating: yob1963.txt
inflating: yob1964.txt
inflating: yob1965.txt
inflating: yob1966.txt
inflating: yob1967.txt
inflating: yob1968.txt
inflating: yob1969.txt
inflating: yob1970.txt
inflating: yob1971.txt
inflating: yob1972.txt
inflating: yob1973.txt
inflating: yob1974.txt
inflating: yob1975.txt
inflating: yob1976.txt
inflating: yob1977.txt
inflating: yob1978.txt
inflating: yob1979.txt
inflating: yob1980.txt
inflating: yob1981.txt
inflating: yob1982.txt
inflating: yob1983.txt
inflating: yob1984.txt
inflating: yob1985.txt
inflating: yob1986.txt
inflating: yob1987.txt
inflating: yob1988.txt
inflating: yob1989.txt
inflating: yob1990.txt
inflating: yob1991.txt
inflating: yob1992.txt
inflating: yob1993.txt
inflating: yob1994.txt
inflating: yob1995.txt
inflating: yob1996.txt
inflating: yob1997.txt
inflating: yob1998.txt
inflating: yob1999.txt
inflating: yob2000.txt
inflating: yob2001.txt
inflating: yob2002.txt
inflating: yob2003.txt
inflating: yob2004.txt
inflating: yob2005.txt
inflating: yob2006.txt
inflating: yob2007.txt
inflating: yob2008.txt
inflating: yob2009.txt
inflating: yob2010.txt
inflating: yob2011.txt
inflating: yob2012.txt
inflating: yob1880.txt
inflating: yob1881.txt
inflating: yob1882.txt
inflating: yob1883.txt
inflating: yob1884.txt
$ cat yob* | grep -E "Kh?al[i|e]*s[i|e]" | awk -F"," '{ s+= $3 } END { print s }'
910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment