Created
April 14, 2012 14:53
-
-
Save tmaeda/2384973 to your computer and use it in GitHub Desktop.
simplenote xml を momonote csv に変換
This file contains hidden or 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
# -*- coding: utf-8 -*- | |
# simplenote xml を momonote csv に変換 | |
require 'nokogiri' | |
require 'csv' | |
require 'time' | |
CSV.open("momonote.csv", "wb", {:col_sep => "\t", :row_sep => "\r\n"}) do |csv| | |
doc = Nokogiri::XML(File.read("simplenote_export_1.xml")) | |
doc.xpath("//note").each do |node| | |
modified = Time.parse(node.xpath("modified").text + " +00:00").utc.strftime("%F %H:%M:%S.%6N %z") | |
content = node.xpath("content").text | |
tags = node.xpath("tags/tag").map(&:text).join(" ") | |
csv << [modified, content, tags] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment