Skip to content

Instantly share code, notes, and snippets.

@dberkholz
Last active August 29, 2015 14:14
Show Gist options
  • Save dberkholz/9c8afdfb1de6fd61a213 to your computer and use it in GitHub Desktop.
Save dberkholz/9c8afdfb1de6fd61a213 to your computer and use it in GitHub Desktop.
Finding Scandinavian fields in a census CSV
# The FPAT snippet allows for commas embedded within double-quotes.
# See https://www.gnu.org/software/gawk/manual/html_node/Splitting-By-Content.html
head -n2 nhgis0302_ds99_1970_state.csv | tail -n1 | awk 'BEGIN {FPAT = "([^,]*)|(\"[^\"]+\")"} {for (i=1;i<=NF;i++) {if ($i ~ /(Swed|Norw|Fin[nl]|Icela|Scand|Danish|Denm)/) print i, $i}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment