Ruben Laguna's blog

Jan 3, 2010 - 2 minute read - blinklist bookmarks comma separated values csv del.icio.us delicious html migrating migration ruby script tab

Migrating from Blinklist to Delicious.com: CSV to HTML

Apparently blinklist doesn’t export bookmarks to JSON format any longer and delicious has changed authentication scheme for its delicious API for new accounts (now it forces new users to use the OAuth / Yahoo ID). So the solutions described in this old post of mine doesn’t work.

So given the current state of affairs the only way to get your bookmarks out of Blinklist is CSV (actually tab-separated) and the only easy way to import them to delicious is to use the HTML import. So we need a way to transforms Blinklist’s CSV to HTML bookmark file format. So I created this ruby scripts that takes bookmark.csv and generates bookmarks.html that you can import to delicious.

#!/usr/bin/ruby
require "rubygems"
require "csv"

i=0
File.open('bookmarks.html', 'w') do |f|
f.print <<EOF
  <!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">

<!-- This is an automatically generated file.
  It will be read and overwritten.
  Do Not Edit! -->
<TITLE>
Bookmarks

</TITLE>
<H1>
Bookmarks

</H1>
<DL>
<p>
EOF

CSV.open('bookmark.csv','r',"\t") do |item|
  next if item[0] == "url"
  i += 1
  puts "#{i}: #{item[0]}" #the url is position 0
  puts "#{i}: #{item[1]}" #the name is position 1
  puts "#{i}: #{item[3]}" #the tags are in position 3
  #next if i > 3229
  #r.add(item[0],item[1],"no description", getTags(item), getTime(item), true, getIsPrivate(item)) #url, name,tags,time,
  f.puts "

  <DT>
  <A HREF=\"#{item[0]}\" LAST_VISIT=\"1248434357\" ADD_DATE=\"1248434357\" TAGS=\"#{item[3]}\">#{item[1]}</A>"
end
f.puts "

</DL>
<p>
"
end
puts "ended";

UPDATE: It seems that in newer version of ruby there are changes in the csv module+

#!/usr/bin/ruby
require "rubygems"
require "csv"

i=0
File.open('bookmarks.html', 'w') do |f|
f.print <<EOF
  <!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">

<!-- This is an automatically generated file.
  It will be read and overwritten.
  Do Not Edit! -->
<TITLE>
Bookmarks

</TITLE>
<H1>
Bookmarks

</H1>
<DL>
<p>
EOF

CSV.foreach('bookmark.csv',{:col_sep => "\t"}) do |item|
  next if item[0] == "url"
  i += 1
  puts "#{i}: #{item[0]}" #the url is position 0
  puts "#{i}: #{item[1]}" #the name is position 1
  puts "#{i}: #{item[2]}" #the description is in position 2
  puts "#{i}: #{item[3]}" #the tags are in position 3
  #next if i > 3229
  #r.add(item[0],item[1],"no description", getTags(item), getTime(item), true, getIsPrivate(item)) #url, name,tags,time,
  f.puts "

  <DT>
  <A HREF=\"#{item[0]}\" LAST_VISIT=\"1248434357\" ADD_DATE=\"1248434357\" TAGS=\"#{item[3]}\">#{item[1]}</A>

  <DD>
  #{item[2]}"
end
f.puts "

</DL>
<p>
"
end
puts "ended";