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