Created
October 9, 2016 14:48
-
-
Save yasugahira0810/bae58a96ec236eff25b507d755d402a2 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
=begin | |
Group Watcherで生成したCSVの開始日と開始時刻、 | |
および終了日と終了時刻を一列にまとめて、 | |
elasticsearchのdate型に合わせる。 | |
Group Watcherが生成するCSVのヘッダは次の通り。 | |
"開始日","開始時刻","終了日","終了時刻","件名", | |
"場所","公/非","分類","グループ名","ユーザー名", | |
"内容","アラーム オン/オフ","アラーム日付","アラーム時刻" | |
=end | |
require 'csv' | |
header, *datas = CSV.read(ARGV[0]) | |
header.delete_at(0) # 「開始日」ヘッダを削除 | |
header.delete_at(1) # 「終了日」ヘッダを削除 | |
datas.each do |d| | |
d[1] = d[0].gsub!(/\//, '-') + "T" + d[1] + "+09:00" # 開始日と開始時刻を結合して、開始時刻列に書き込む | |
d[3] = d[2].gsub!(/\//, '-') + "T" + d[3] + "+09:00" | |
d.delete_at(0) # 「開始日」データを削除 | |
d.delete_at(1) | |
end | |
output = CSV.generate do |csv| | |
csv << header | |
datas.each do |d| | |
csv << d | |
end | |
end | |
puts output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment