Created
August 1, 2012 07:55
-
-
Save tekei/3224735 to your computer and use it in GitHub Desktop.
アウトラインプロセッサのファイル変換 (Outliner -> AUTRA)
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
# androidのアウトラインプロセッサ "Outliner"から | |
# Windowsのアウトラインプロセッサ "あうとら"へのファイル変換 | |
# | |
# Outlinerでは、「bonsai CSV (UTF-8)」としてエクスポート。 | |
# あうとらでは、インポートメニューから取り込み。 | |
require "csv" | |
csv_file_name = ARGV[0] | |
unless csv_file_name =~ /\.csv$/ | |
puts "CSVファイルではありません" | |
exit | |
end | |
txt_file_name = csv_file_name.sub(/(.*)\.csv$/) { "#{$1}.txt" } | |
open(txt_file_name, "w:windows-31j") do |f| | |
CSV.open(csv_file_name, 'r:utf-8') do |c| | |
c.each do |row| | |
level = row[3].to_i + 1 | |
title = row[0] | |
body = row[14] | |
f << "".center(level, '.') + title + "\n" + body + "\n" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment