Skip to content

Instantly share code, notes, and snippets.

@tekei
Created August 1, 2012 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekei/3224735 to your computer and use it in GitHub Desktop.
Save tekei/3224735 to your computer and use it in GitHub Desktop.
アウトラインプロセッサのファイル変換 (Outliner -> AUTRA)
# 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