Skip to content

Instantly share code, notes, and snippets.

@tmaeda
Created April 14, 2012 14:53
Show Gist options
  • Save tmaeda/2384973 to your computer and use it in GitHub Desktop.
Save tmaeda/2384973 to your computer and use it in GitHub Desktop.
simplenote xml を momonote csv に変換
# -*- 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