Skip to content

Instantly share code, notes, and snippets.

@neilernst
Created September 4, 2010 19:34
Show Gist options
  • Save neilernst/565427 to your computer and use it in GitHub Desktop.
Save neilernst/565427 to your computer and use it in GitHub Desktop.
Find citation keys using Mendeley
#!/usr/bin/ruby
require 'sqlite3'
cite_part = ARGV[0]
db_name = "/Users/nernst/Library/Application\ Support/Mendeley\ Desktop/neil\@neilernst.net\@www.mendeley.com.sqlite"
db = SQLite3::Database.new( db_name )
db.results_as_hash = true
query = "select citationkey, title, year from Documents where citationkey like '%#{cite_part}%'"#MATCH '#{cite_part}'"#{}like '%#{cite_part}%'"
db.execute( query ) do |row|
print row['citationKey'] + '|'
#print '@row:' + row['citationKey'] + "|" + row['title'] + "|" + row['year'].to_s
end
on run {input, parameters}
set cite to input --"" --"jureta"
set delimitedList to {}
-- set test to "Carvalho2005a|Hayes2008|Sampaio2005|Sawyer2002|Searle1976|Baker|Denecker2002|Liu2009|Anbulagan2009"
set ssresult to do shell script "/Users/nernst/Desktop/query_cite.rb " & cite as string
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "|"
set delimitedList to every text item of ssresult
set y to choose from list delimitedList
set AppleScript's text item delimiters to tid
return y
end run
@neilernst
Copy link
Author

No, I haven't. I would recommend posting on the Mendeley website and forums about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment