Migrating zotero notes

Hello everyone,

Apologies if this is something that has been asked before. I’ve been reading through some threads here for a workflow that includes zotero and org-roam/ orb but did not find anything (so far) on this particular issue.

I am interested in setting up an org-roam/orb personal repository of notes. I already use org-mode to write latex files. And I use ivy-bibtex as a toolkit for the .bib file produced by zotero (which manages all my references and pdf files). Over the years I have made hundreds of notes on zotero, each associated with a specific bibtex entry. My question is this: is there a painless way of getting all of those notes from zotero into my org-roam database (using some sort of automated capture template perhaps?) or will I have to copy and paste those notes manually from zotero into the org-roam entry for that bibtex file?

I haven’t been using Zotero for years and can’t remember how Zotero notes are organized. But maybe this thread on ORB’s Github could be helpful? It’s about some Zotero annotations.

This is very helpful, thank you. I will take a look at the solution and try to implement it.

I found some interesting behavior that I think I have narrowed down to the function bibtex-completion-get-value

I tried to capture all of my notes from my bibtex file into an org roam node for a bibliographic entry using the following code:

(defun my-orb-latex-note-to-org (citekey)
  (let* ((entry (bibtex-completion-get-entry citekey))
         (note (bibtex-completion-apa-get-value "note" entry ""))
         (pandoc-command "pandoc --from latex --to org")
         result)
    (with-temp-buffer
      (shell-command (format "echo \"%s\" | %s" note pandoc-command)
                     (current-buffer))
      (setq result (buffer-substring-no-properties (point-min) (point-max))))))

(setq orb-preformat-keywords '("citekey" "author" "date" "note" "booktitle" "title" "=key=" "url" "file" "keywords" "author-or-editor"))
(setq org-roam-capture-templates
      '(
	("d" "default" plain "%?"
	 :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
	 :unnarrowed t)
        ("b" "bibliography reference" plain "#+filetags ::
#+keywords :: %^{keywords}
#+author(s) :: %^{author-or-editor}\n\n
%?"
         :target
         (file+head "references/${citekey}.org" "#+title: ${title}\n")
         :unnarrowed t)
	("r" "bibliography reference with raw zotero note" plain "#+filetags ::
#+keywords :: %^{keywords}
#+author(s) :: %^{author-or-editor}\n\n
\n* Notes (from zotero)\n\n
%^{note} %?"
         :target
         (file+head "references/${citekey}.org" "#+title: ${title}\n")
         :unnarrowed t)
	("z" "bibliography reference with zotero note" plain "#+filetags ::
#+keywords :: %^{keywords}
#+author(s) :: %^{author-or-editor}\n\n
\n* Notes (from zotero)\n\n
%(my-orb-latex-note-to-org \"${citekey}\") %?"
         :target
         (file+head "references/${citekey}.org" "#+title: ${title}\n")
         :unnarrowed t)))

Nearly every attempt resulted in a pandoc error like the following:



Error at (line 2, column 2):
unexpected end of input
expecting \end{itemize}

 ^

So it seems like the bibtex file may have some formatting errors. Which is strange because it is automatically generated by better biblatex in zotero.

In any case, I tried to create a new note in zotero, that updated my bib file, and when I ran the above code on the new note it worked fine and formatted the notes correctly for an org file.

I am not sure what the issue is here. But having run the same file that gave me the error above through the capture I defined above under the binding “r” that returned just the expansion of %^{note} I noticed that the latex string it produced was missing a curly bracket at the end. So the last line was like this: \end{itemize

Having spent some time looking through the orb .el file, it looks like the pre-expansion is handled by the same function: bibtex-completion-get-value

I am assuming that for whatever reason, this function is too eagerly cutting brackets when parsing the bibtex file. The bibtex entry that was giving me this error is the following:

@incollection{alstonEpistemicDisederataApproach2005,
  title = {3. {{The Epistemic Disederata Approach}}},
  booktitle = {Beyond "{{Justification}}": {{Dimensions}} of {{Epistemic Evaluation}}},
  author = {Alston, William P.},
  date = {2005},
  pages = {39--57},
  publisher = {{Ithaca: Cornell University Press}},
  keywords = {\#Noted,pluralism about justification},
  note = {\section{Beyond Justification (Alston 2005)}

\subsection{3. The Epistemic Disederata Approach (pp. 39-57)}

\par
\begin{itemize}

\item We can split positive epistemic disederata across broad categories of truth-conduciveness (adequacy, reliability etc), discriminatory aids (evidence, well-grounded belief etc), deontological categories (responsible belief), and cognitive goals (understanding, coherence etc)

\item Which of these standards is more important will be dynamically updated depending on the context

\item Some will always be more core or fundamental than others (namely the truth-conducive group)

\item But this justifies a general pluralism about epistemic disederata -- there are many and they are relatively important depending on what we think

\item For instance, once this approach is adopted the disputes around Norman dissipate -- under some disederata he is in a positive position (reliability etc) and others he is not -- the further question of whether he is justified is just not a live question anymore -- we can drop the word justification altogether

\end{itemize}

\par
\begin{itemize}

\item Claims that cognitive goals like understanding are not related to aim for truth directly but what is it to understand something except to gather contextual truths about it?

\item Is the issue of Norman genuinely resolved or just pushed back a step -- everyone already knows that different theorists apply different standards of positive epistemic status to Norman, this is not news, but the dispute remains live, because there are other questions where justification doesn't even come up like -- is it legitimate for Norman to travel to New York to see the president on the basis of his clairvoyant (true) belief that she is in that city -- this will bring back all the same issues and we didn't even have to use the word justification 

\end{itemize}}
}

Yep, that doesn’t surprise me. ORB’s transiently using bibtex-completion-get-value for a lack of a better alternative, but this will change somewhen in the future. Meanwhile, you can define your own get-value function that would trim at most one pair of braces if any and plug it into orb-bibtex-entry-get-value-function.

Ah so it is not an unknown issue. Yes, I’ve hacked together something that works for now, thanks for the help. Interested to hear about the alternative, whenever it gets pushed.

1 Like

@aflatoon do you mind sharing how you’ve solved the issue?

I’ve been looking to do something very similar when I stumbled across this thread.