用mapreduce 處理氣象資料集

2022-08-18 22:00:21 字數 1414 閱讀 3376

用mapreduce 處理氣象資料集

編寫程式求每日最高最低氣溫,區間最高最低氣溫

解壓資料集,並儲存在文字檔案中

對氣象資料格式進行解析

編寫map函式,reduce函式

將其許可權作出相應修改

本機上測試執行**

放到hdfs上執行將之前爬取的文字檔案上傳到hdfs上

用hadoop streaming命令提交任務

檢視執行結果

cd /usr/hadoop

sodu mkdir qx

cd /usr/hadoop/qx

wget -d --accept-regex=regex -p data -r -c /usr/hadoop/qx/data/ftp.ncdc.noaa.gov/pub/data/noaa/2017sudo zcat 1*.gz >qxdata.txt

cd /usr/hadoop/qx

#!/usr/bin/env python

import

sysfor i in

sys.stdin:

i =i.strip()

d = i[15:23]

t = i[87:92]

print

'%s\t%s

' %(d,t)

#!/usr/bin/env python

from operator import

itemggetter

import

syscurrent_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

:

ifcurrent_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/reducer.py

用mapreduce 處理氣象資料集

用mapreduce 處理氣象資料集 編寫程式求每日最高最低氣溫,區間最高最低氣溫 解壓資料集,並儲存在文字檔案中 對氣象資料格式進行解析 編寫map函式,reduce函式 將其許可權作出相應修改 本機上測試執行 放到hdfs上執行將之前爬取的文字檔案上傳到hdfs上 用hadoop streami...

用mapreduce 處理氣象資料集

編寫程式求每日最高最低氣溫,區間最高最低氣溫 解壓資料集,並儲存在文字檔案中 對氣象資料格式進行解析 編寫map函式,reduce函式 將其許可權作出相應修改 本機上測試執行 放到hdfs上執行將之前爬取的文字檔案上傳到hdfs上 用hadoop streaming命令提交任務 檢視執行結果12 3...

用mapreduce 處理氣象資料集

本次的所有操作均在當前使用者目錄下的 temp 2018 05 09中 wget drc accept regex regex p data 在這之前,需要配置好環境,在.bashrc中加入下面的命令 export path path usr local hbase bin usr local ha...