Last active
August 8, 2017 12:34
-
-
Save bfritz/08e4c6495a1293d391f0d40d295f1a74 to your computer and use it in GitHub Desktop.
rapture-csv in Ammonite REPL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
territory_id | first_name | last_name | employee_id | ||
---|---|---|---|---|---|
XMOWSM54 | Peter | Alexander | [email protected] | E00QTOF | |
XMRNBM47 | Samuel | Lopez | [email protected] | E00UBFA | |
XMOWMF87 | Elizabeth | Stone | [email protected] | E00WDYK | |
XMZWPW22 | William | Carroll | [email protected] | E00VDYQ | |
XMOWRW46 | Carolyn | Little | [email protected] | E00HUPR | |
XMZNDX26 | Marilyn | Robinson | [email protected] | E00ZJGS | |
XMZNAI68 | Christopher | Rogers | [email protected] | E00DCHF | |
XMONCD74 | Anthony | Allen | [email protected] | E00ACEQ | |
XMRNMD81 | Martin | Baker | [email protected] | E00DKRZ | |
XMZWEP67 | Kenneth | Black | [email protected] | E00WPRM | |
XMONMU36 | Ernest | Harper | [email protected] | E00QEMW | |
XMOWYQ05 | Kathryn | Morris | [email protected] | E00GNRI | |
XMONGU42 | Sarah | Garza | [email protected] | E00LVWB | |
XMZNZL99 | Arthur | Young | [email protected] | E00HAQN | |
XMZNSB40 | Harry | Butler | [email protected] | E00ETYF | |
XMONIR25 | Janet | Knight | [email protected] | E00PGJO | |
XMOWQS30 | Kelly | Hernandez | [email protected] | E00VWFM | |
XMRNVO18 | Tammy | Banks | [email protected] | E00VBPJ | |
XMZWGN33 | Deborah | Cole | [email protected] | E00LSNA | |
XMZWIZ28 | Frances | Holmes | [email protected] | E00APTS | |
XMONGA47 | Christina | Burns | [email protected] | E00DGIB | |
XMRNKF51 | Jason | Mills | [email protected] | E00EZNU | |
XMZNDT10 | Ernest | Day | [email protected] | E00UMVH | |
XMOWGY81 | Joan | Rivera | [email protected] | E00PCLK | |
XMZWHG83 | Nancy | Hudson | [email protected] | E00CITD | |
XMRNIH32 | Kimberly | Thomas | [email protected] | E00VIUQ | |
XMZNZH01 | Catherine | Fowler | [email protected] | E00DCZJ | |
XMZNNC54 | Laura | Hernandez | [email protected] | E00CNUG | |
XMRWQC06 | Theresa | Burke | [email protected] | E00UNHR | |
XMONDL08 | Tina | Warren | [email protected] | E00SQVC | |
XMOWEK42 | Thomas | Lynch | [email protected] | E00FBYQ | |
XMZWSR67 | Juan | Allen | [email protected] | E00UWNR | |
XMOWOD21 | Jane | Mendoza | [email protected] | E00CSRE | |
XMZWFQ07 | Russell | Andrews | [email protected] | E00LRGI | |
XMONQE94 | Kathy | White | [email protected] | E00VKGN | |
XMRWRU95 | Judith | Snyder | [email protected] | E00QTIU | |
XMONNW27 | Carl | Nichols | [email protected] | E00EGOX | |
XMZWDV58 | Karen | Elliott | [email protected] | E00JBLR | |
XMZNBK56 | Thomas | Grant | [email protected] | E00TRBD | |
XMONQF71 | James | Coleman | [email protected] | E00PFGR | |
XMZNGQ51 | Brenda | Bennett | [email protected] | E00JKWR | |
XMZNPH94 | Victor | Hart | [email protected] | E00PMLO | |
XMZWCL63 | Joseph | Richards | [email protected] | E00VQOE | |
XMZNTH41 | Justin | Stanley | [email protected] | E00PQCL | |
XMZNBB01 | Carlos | Smith | [email protected] | E00FCJD | |
XMOWDI95 | Stephanie | Martinez | [email protected] | E00BPYS | |
XMZNJQ72 | Keith | Franklin | [email protected] | E00CIHT | |
XMONKA16 | Bruce | Andrews | [email protected] | E00BYCI | |
XMONKX98 | Antonio | Rose | [email protected] | E00CETA | |
XMZNBM97 | Chris | Boyd | [email protected] | E00XAPQ | |
XMZNWO30 | Stephanie | Dunn | [email protected] | E00GOKP | |
XMOWXQ66 | Phillip | Perez | [email protected] | E00GXEZ | |
XMZWLI99 | James | Garza | [email protected] | E00KZHP | |
XMZWXT45 | Richard | Cunningham | [email protected] | E00CKUV | |
XMZWYI99 | Carlos | Hart | [email protected] | E00ZLUK | |
XMZNWW61 | William | Rice | [email protected] | E00CMST | |
XMOWZO24 | Patrick | Kennedy | [email protected] | E00GEHS | |
XMRNAZ74 | Lillian | Nguyen | [email protected] | E00YXNC | |
XMOWAK57 | Matthew | Reyes | [email protected] | E00RGEF | |
XMOWTF81 | Eric | Andrews | [email protected] | E00SZGA | |
XMOWEN19 | Brian | Freeman | [email protected] | E00KYJV | |
XMONEC87 | Joe | Payne | [email protected] | E00HMIZ | |
XMZNJJ44 | Edward | Berry | [email protected] | E00QSEO | |
XMRNBD66 | Karen | Banks | [email protected] | E00CJPF | |
XMRWGU30 | Diane | Mcdonald | [email protected] | E00QSFJ | |
XMRNKL43 | Lois | Harris | [email protected] | E00ZPKT | |
XMZWPB73 | Marilyn | Coleman | [email protected] | E00QIHW | |
XMRWUS18 | Jacqueline | Alexander | [email protected] | E00CPJM | |
XMONWK31 | Donald | Adams | [email protected] | E00MIBW | |
XMOWAV47 | Virginia | Anderson | [email protected] | E00IUMO | |
XMZWBH32 | Anna | Hayes | [email protected] | E00HRCU | |
XMONPK26 | Thomas | Jacobs | [email protected] | E00KPQA | |
XMZWNO54 | Amanda | Peters | [email protected] | E00JKZC | |
XMONUH49 | Martha | Lane | [email protected] | E00KQDG | |
XMRNFA05 | Anne | Price | [email protected] | E00HYPJ | |
XMRNRF73 | Craig | Garrett | [email protected] | E00NXAG | |
XMZWZH49 | Andrea | Castillo | [email protected] | E00IXDN | |
XMRNLD81 | Deborah | Sanders | [email protected] | E00HQOG | |
XMONXS56 | Gerald | Crawford | [email protected] | E00YNSB | |
XMZWES74 | Donald | Palmer | [email protected] | E00WCON | |
XMZWQZ17 | Kathy | Welch | [email protected] | E00IACR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
territory_id | first_name | last_name | employee_id | ||
---|---|---|---|---|---|
NP00 | Peter | Alexander | [email protected] | E00QTOF | |
NP01 | Samuel | Lopez | [email protected] | E00UBFA | |
NP02 | Elizabeth | Stone | [email protected] | E00WDYK | |
NP03 | William | Carroll | [email protected] | E00VDYQ | |
NP06 | Carolyn | Little | [email protected] | E00HUPR | |
NP07 | Marilyn | Robinson | [email protected] | E00ZJGS | |
NP08 | Christopher | Rogers | [email protected] | E00DCHF | |
NP10 | Anthony | Allen | [email protected] | E00ACEQ | |
NP12 | Martin | Baker | [email protected] | E00DKRZ | |
NP14 | Kenneth | Black | [email protected] | E00WPRM | |
NP15 | Ernest | Harper | [email protected] | E00QEMW | |
NP16 | Kathryn | Morris | [email protected] | E00GNRI | |
NP18 | Sarah | Garza | [email protected] | E00LVWB | |
NP20 | Arthur | Young | [email protected] | E00HAQN | |
NP21 | Harry | Butler | [email protected] | E00ETYF | |
NP22 | Janet | Knight | [email protected] | E00PGJO | |
NP23 | Kelly | Hernandez | [email protected] | E00VWFM | |
NP24 | Tammy | Banks | [email protected] | E00VBPJ | |
NP25 | Deborah | Cole | [email protected] | E00LSNA | |
NP26 | Frances | Holmes | [email protected] | E00APTS | |
NP27 | Christina | Burns | [email protected] | E00DGIB | |
P000 | Jason | Mills | [email protected] | E00EZNU | |
PM00 | Ernest | Day | [email protected] | E00UMVH | |
PMC0 | Joan | Rivera | [email protected] | E00PCLK | |
PMC2 | Nancy | Hudson | [email protected] | E00CITD | |
PMC3 | Kimberly | Thomas | [email protected] | E00VIUQ | |
PMC4 | Catherine | Fowler | [email protected] | E00DCZJ | |
PMC6 | Laura | Hernandez | [email protected] | E00CNUG | |
PMC7 | Theresa | Burke | [email protected] | E00UNHR | |
PME0 | Tina | Warren | [email protected] | E00SQVC | |
PME1 | Thomas | Lynch | [email protected] | E00FBYQ | |
PME2 | Juan | Allen | [email protected] | E00UWNR | |
PME4 | Jane | Mendoza | [email protected] | E00CSRE | |
PME5 | Russell | Andrews | [email protected] | E00LRGI | |
PME6 | Kathy | White | [email protected] | E00VKGN | |
PME7 | Judith | Snyder | [email protected] | E00QTIU | |
PMN2 | Carl | Nichols | [email protected] | E00EGOX | |
PMN3 | Karen | Elliott | [email protected] | E00JBLR | |
PMN4 | Thomas | Grant | [email protected] | E00TRBD | |
PMW0 | James | Coleman | [email protected] | E00PFGR | |
PMW1 | Brenda | Bennett | [email protected] | E00JKWR | |
PMW3 | Victor | Hart | [email protected] | E00PMLO | |
PMW4 | Joseph | Richards | [email protected] | E00VQOE | |
PMW5 | Justin | Stanley | [email protected] | E00PQCL | |
PMW6 | Carlos | Smith | [email protected] | E00FCJD | |
PMW7 | Stephanie | Martinez | [email protected] | E00BPYS | |
PO00 | Keith | Franklin | [email protected] | E00CIHT | |
POE0 | Bruce | Andrews | [email protected] | E00BYCI | |
POE1 | Antonio | Rose | [email protected] | E00CETA | |
POE2 | Chris | Boyd | [email protected] | E00XAPQ | |
POE4 | Stephanie | Dunn | [email protected] | E00GOKP | |
POE5 | Phillip | Perez | [email protected] | E00GXEZ | |
POE6 | James | Garza | [email protected] | E00KZHP | |
POE7 | Richard | Cunningham | [email protected] | E00CKUV | |
POW1 | Carlos | Hart | [email protected] | E00ZLUK | |
POW3 | William | Rice | [email protected] | E00CMST | |
POW4 | Patrick | Kennedy | [email protected] | E00GEHS | |
POW5 | Lillian | Nguyen | [email protected] | E00YXNC | |
POW7 | Matthew | Reyes | [email protected] | E00RGEF | |
PR00 | Eric | Andrews | [email protected] | E00SZGA | |
PR01 | Brian | Freeman | [email protected] | E00KYJV | |
PR02 | Joe | Payne | [email protected] | E00HMIZ | |
PR03 | Edward | Berry | [email protected] | E00QSEO | |
PR05 | Karen | Banks | [email protected] | E00CJPF | |
PR06 | Diane | Mcdonald | [email protected] | E00QSFJ | |
PR07 | Lois | Harris | [email protected] | E00ZPKT | |
PR08 | Marilyn | Coleman | [email protected] | E00QIHW | |
PR09 | Jacqueline | Alexander | [email protected] | E00CPJM | |
PR10 | Donald | Adams | [email protected] | E00MIBW | |
PR12 | Virginia | Anderson | [email protected] | E00IUMO | |
PRE0 | Anna | Hayes | [email protected] | E00HRCU | |
PRW0 | Thomas | Jacobs | [email protected] | E00KPQA | |
PSC0 | Amanda | Peters | [email protected] | E00JKZC | |
PSN3 | Martha | Lane | [email protected] | E00KQDG | |
PSN5 | Anne | Price | [email protected] | E00HYPJ | |
PSN6 | Craig | Garrett | [email protected] | E00NXAG | |
PT01 | Andrea | Castillo | [email protected] | E00IXDN | |
PW00 | Deborah | Sanders | [email protected] | E00HQOG | |
PWN1 | Gerald | Crawford | [email protected] | E00YNSB | |
PWN4 | Donald | Palmer | [email protected] | E00WCON | |
PX00 | Kathy | Welch | [email protected] | E00IACR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "2.11.8" | |
// copied from http://www.lihaoyi.com/Ammonite/#Ammonite-REPLinSBT | |
libraryDependencies += "com.lihaoyi" % "ammonite-repl" % "0.5.7" % | |
"test" cross CrossVersion.full | |
initialCommands in (Test, console) := """ammonite.repl.Main.run("")""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// started with `s// start REPL with `sbt test:console` | |
load.ivy("com.propensive" %% "rapture-csv" % "2.0.0-M5") | |
import rapture.uri._ | |
// to support "file://" URLs | |
import rapture.fs._ | |
val file_before = uri"file:///tmp/before.csv" | |
val file_after = uri"file:///tmp/after.csv" | |
// so we know how to decode the bytes on disk | |
import rapture.codec.encodings.`UTF-8`._ | |
// so we know how to parse CSV | |
import rapture.csv._ | |
import rapture.csv.csvBackends.simple._ | |
val c1 = Csv.parse(file_before) | |
val c2 = Csv.parse(file_after) | |
// now we can explore, for example... | |
c1.filter( i => i(1).toString.startsWith("F") ) | |
// goal: map old territory IDs to new | |
// we'll include a filter to keep the results smaller for discussion | |
val letter = "J" | |
val byEmp1 = c1. | |
filter( i => i(1).toString.startsWith(letter) ). | |
map( i => ( i(4).toString, i(0).toString ) ).toMap | |
val byEmp2 = c2. | |
filter( i => i(1).toString.startsWith(letter) ). | |
map( i => ( i(4).toString, i(0).toString ) ).toMap | |
val mapping = byEmp1.map( b => (b._2, byEmp2(b._1) ) ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment