Skip to content

Instantly share code, notes, and snippets.

@asmega
Last active September 18, 2022 15:32
Show Gist options
  • Save asmega/b30ecd554adaf2e1c10a39ad7b15a3d1 to your computer and use it in GitHub Desktop.
Save asmega/b30ecd554adaf2e1c10a39ad7b15a3d1 to your computer and use it in GitHub Desktop.
ticktick csv export
require "csv"
require "pry"
rows = CSV.read("./ticktick.csv", headers: true)
rows = rows.select { |row| row["Completed Time"].nil? }
CSV.open("./ticktick2.csv", "w") do |csv|
csv << rows[0].headers
rows.each do |row|
csv << row.fields
end
end
hash = {}
rows.each do |row|
hash[row["List Name"]] ||= []
hash[row["List Name"]] << "#{row['Title']} #{row['Content']}"
end
hash.each do |key,v|
CSV.open("./tick-#{key.gsub(' ', '-')}.csv", "w") do |csv|
v.each do |item|
csv << [item]
end
end
end
# binding.pry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment