标签:none 函数 mkdir import 分享图片 color 区间 sys lse
用mapreduce 处理气象数据集
编写程序求每日最高最低气温,区间最高最低气温
cd /usr/hadoop
sodu mkdir qx
cd /usr/hadoop/qx
wget -D --accept-regex=REGEX -P data -r -c ftp://ftp.ncdc.noaa.gov/pub/data/noaa/2017/1*
cd /usr/hadoop/qx/data/ftp.ncdc.noaa.gov/pub/data/noaa/2017
sudo zcat 1*.gz >qxdata.txt
cd /usr/hadoop/qx
import sys
for i in sys.stdin:
i = i.strip()
d = i[15:23]
t = i[87:92]
print ‘%s\t%s‘ % (d,t)
from operator import itemggetter
import sys
current_word = None
current_count = 0
word = None
for i in sys.stdin:
i = i.strip()
word,count = i.split(‘\t‘, 1)
try:
count = int(count)
except ValueError:
continue
if current_word == word:
if current_count > count:
current_count = count
else:
if current_word:
print ‘%s\t%s‘ % (current_word, current_count)
current_count = count
current_word = word
if current_word == word:
print ‘%s\t%s‘ % (current_word, current_count)
chmod a+x /usr/hadoop/qx/mapper.py
chmod a+x /usr/hadoop/qx/reducer.py
标签:none 函数 mkdir import 分享图片 color 区间 sys lse
原文地址:https://www.cnblogs.com/metalblog/p/9016825.html