ga_mapper.R 970 B

123456789101112131415161718192021222324
  1. #! /usr/bin/env Rscript
  2. # To disable the warning massages to be printed
  3. options(warn=-1)
  4. # To initiating the connection to standard input
  5. input = file("stdin", "r")
  6. # 从原始数据中读取每行,取出每行city,pagepath,输出给reduce
  7. while(length(currentLine = readLines(input, n=1, warn=FALSE)) > 0) {
  8. fields = unlist(strsplit(currentLine, ","))
  9. # Capturing the city and pagePath from fields
  10. city = as.character(fields[3])
  11. pagepath = as.character(fields[4])
  12. # Printing bith to the standard output
  13. print(paste(city,pagepath,sep="\t"),stdout())
  14. }
  15. # Closing the connection to that input stream
  16. close(input)