Ruben Laguna’s blog

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<span class='line'>#!/usr/bin/ruby
</span><span class='line'>require "rubygems"
</span><span class='line'>require "csv" 
</span><span class='line'>
</span><span class='line'>i=0
</span><span class='line'>File.open('bookmarks.html', 'w') do |f|   
</span><span class='line'>  f.print &lt;&lt;EOF
</span><span class='line'>  &lt;!DOCTYPE NETSCAPE-Bookmark-file-1>
</span><span class='line'>  &lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</span><span class='line'>  &lt;!-- This is an automatically generated file.
</span><span class='line'>  It will be read and overwritten.
</span><span class='line'>  Do Not Edit! -->
</span><span class='line'>  &lt;TITLE>Bookmarks&lt;/TITLE>
</span><span class='line'>  &lt;H1>Bookmarks&lt;/H1>
</span><span class='line'>  &lt;DL>&lt;p>
</span><span class='line'>EOF
</span><span class='line'>
</span><span class='line'>  CSV.open('bookmark.csv','r',"\t") do  |item|
</span><span class='line'>    next if item[0] == "url"
</span><span class='line'>    i += 1
</span><span class='line'>    puts "#{i}: #{item[0]}" #the url is position 0 
</span><span class='line'>    puts "#{i}: #{item[1]}" #the name is position 1 
</span><span class='line'>    puts "#{i}: #{item[3]}" #the tags are in position 3
</span><span class='line'>    #next if i > 3229
</span><span class='line'>    #r.add(item[0],item[1],"no description", getTags(item), getTime(item), true, getIsPrivate(item)) #url, name,tags,time,
</span><span class='line'>    f.puts "&lt;DT>&lt;A HREF=\"#{item[0]}\" LAST_VISIT=\"1248434357\" ADD_DATE=\"1248434357\" TAGS=\"#{item[3]}\">#{item[1]}&lt;/A>"
</span><span class='line'>  end 
</span><span class='line'>  f.puts "&lt;/DL>&lt;p>"
</span><span class='line'>end
</span><span class='line'>puts "ended";</span>

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<span class='line'>#!/usr/bin/ruby
</span><span class='line'>require "rubygems"
</span><span class='line'>require "csv" 
</span><span class='line'>
</span><span class='line'>i=0
</span><span class='line'>File.open('bookmarks.html', 'w') do |f|
</span><span class='line'>  f.print &lt;&lt;EOF
</span><span class='line'>  &lt;!DOCTYPE NETSCAPE-Bookmark-file-1>
</span><span class='line'>  &lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</span><span class='line'>  &lt;!-- This is an automatically generated file.
</span><span class='line'>  It will be read and overwritten.
</span><span class='line'>  Do Not Edit! -->
</span><span class='line'>  &lt;TITLE>Bookmarks&lt;/TITLE>
</span><span class='line'>  &lt;H1>Bookmarks&lt;/H1>
</span><span class='line'>  &lt;DL>&lt;p>
</span><span class='line'>EOF
</span><span class='line'>
</span><span class='line'>  CSV.foreach('bookmark.csv',{:col_sep => "\t"}) do  |item|
</span><span class='line'>    next if item[0] == "url"
</span><span class='line'>    i += 1
</span><span class='line'>    puts "#{i}: #{item[0]}" #the url is position 0
</span><span class='line'>    puts "#{i}: #{item[1]}" #the name is position 1
</span><span class='line'>    puts "#{i}: #{item[2]}" #the description is in position 2
</span><span class='line'>    puts "#{i}: #{item[3]}" #the tags are in position 3
</span><span class='line'>    #next if i > 3229
</span><span class='line'>    #r.add(item[0],item[1],"no description", getTags(item), getTime(item), true, getIsPrivate(item)) #url, name,tags,time,
</span><span class='line'>    f.puts "&lt;DT>&lt;A HREF=\"#{item[0]}\" LAST_VISIT=\"1248434357\" ADD_DATE=\"1248434357\" TAGS=\"#{item[3]}\">#{item[1]}&lt;/A>
</span><span class='line'>&lt;DD>#{item[2]}"
</span><span class='line'>  end
</span><span class='line'>  f.puts "&lt;/DL>&lt;p>"
</span><span class='line'>end
</span><span class='line'>puts "ended";</span>

Comments

Copyright © 2015 - Ruben Laguna - Powered by Octopress