Created
September 4, 2010 19:34
-
-
Save neilernst/565427 to your computer and use it in GitHub Desktop.
Find citation keys using Mendeley
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Really useful snippet of code Neil. I've used it to automate some bibliographies, and inserted it into my university's thesis template.
I'm now trying to do some queries of the full text part of the database that Mendeley keeps. Have you been successful with that, or heard of anyone doing it? I don't see the fields that link to the file indexes that the full text is stored in, but I've only started trying to reverse engineer that part.
Thanks,
Ben
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
A ruby and apple script to run sqlite against Mendeley databases. Warning: I wouldn't recommend changing the DB unless you want to mess up the client.
Currently this script does not allow one to see the paper title, which would be good for disambiguation. It was enough work getting lists to display in Applescript.
Getting it to work: