Created
January 29, 2017 18:29
-
-
Save 1stMinos/3081ee9b5671943da78902a7d3485c0e to your computer and use it in GitHub Desktop.
川崎の1時間あたり降水量データから、30ミリ以上のデータを抜き出す
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
require 'spreadsheet' | |
readName = '26hyo2-15.xls' | |
writeName = 'result.xls' | |
#open books | |
readBook = Spreadsheet.open(readName) | |
writeBook = Spreadsheet::Workbook.new | |
readSheet = readBook.worksheet('Ⅱ-15その1') | |
writeSheet = writeBook.create_worksheet(name: 'result') | |
writeSheet.row(0).push readSheet[4,0], readSheet[4,1], '年度', '雨量' | |
k = 0 | |
for i in 5..44 do | |
place1 = readSheet[i,0] | |
place2 = readSheet[i,1] | |
for j in 2..6 do | |
if readSheet[i,j].is_a?(Numeric) && readSheet[i,j] >= 30 | |
k = k + 1 | |
writeSheet.row(k).push place1, place2,readSheet[4,j],readSheet[i,j] | |
end | |
end | |
end | |
writeBook.write(writeName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
昔作ったやつを移植