Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: combining() argument must be a unicode character, not str #54

Closed
brimwats1 opened this issue Dec 14, 2019 · 5 comments
Closed
Labels

Comments

@brimwats1
Copy link

Python 3.8.
Most recent version of academic-admin

PS C:\Users\Brian\Documents\GitHub\me> academic import --bibtex 'C:\Users\Brian\Downloads\MyLibrary.bib' Traceback (most recent call last): File "c:\python38\lib\runpy.py", line 192, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\python38\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Python38\Scripts\academic.exe\__main__.py", line 9, in <module> File "c:\python38\lib\site-packages\academic\cli.py", line 50, in main parse_args(sys.argv[1:]) # Strip command name, leave just args. File "c:\python38\lib\site-packages\academic\cli.py", line 104, in parse_args import_bibtex(known_args.bibtex, File "c:\python38\lib\site-packages\academic\cli.py", line 126, in import_bibtex bib_database = bibtexparser.load(bibtex_file, parser=parser) File "c:\python38\lib\site-packages\bibtexparser\__init__.py", line 71, in load return parser.parse_file(bibtex_file) File "c:\python38\lib\site-packages\bibtexparser\bparser.py", line 177, in parse_file return self.parse(file.read(), partial=partial) File "c:\python38\lib\site-packages\bibtexparser\bparser.py", line 155, in parse self._expr.parseFile(bibtex_file_obj) File "c:\python38\lib\site-packages\bibtexparser\bibtexexpression.py", line 286, in parseFile return self.main_expression.parseFile(file_obj, parseAll=True) File "c:\python38\lib\site-packages\pyparsing.py", line 2561, in parseFile return self.parseString(file_contents, parseAll) File "c:\python38\lib\site-packages\pyparsing.py", line 1935, in parseString loc, tokens = self._parse(instring, 0) File "c:\python38\lib\site-packages\pyparsing.py", line 1675, in _parseNoCache loc, tokens = self.parseImpl(instring, preloc, doActions) File "c:\python38\lib\site-packages\pyparsing.py", line 4762, in parseImpl return super(ZeroOrMore, self).parseImpl(instring, loc, doActions) File "c:\python38\lib\site-packages\pyparsing.py", line 4688, in parseImpl loc, tmptokens = self_expr_parse(instring, preloc, doActions) File "c:\python38\lib\site-packages\pyparsing.py", line 1675, in _parseNoCache loc, tokens = self.parseImpl(instring, preloc, doActions) File "c:\python38\lib\site-packages\pyparsing.py", line 4235, in parseImpl ret = e._parse(instring, loc, doActions) File "c:\python38\lib\site-packages\pyparsing.py", line 1708, in _parseNoCache tokens = fn(instring, tokensStart, retTokens) File "c:\python38\lib\site-packages\pyparsing.py", line 1314, in wrapper ret = func(*args[limit[0]:]) File "c:\python38\lib\site-packages\bibtexparser\bparser.py", line 203, in <lambda> lambda s, l, t: self._add_entry( File "c:\python38\lib\site-packages\bibtexparser\bparser.py", line 299, in _add_entry d = self.customization(d) File "c:\python38\lib\site-packages\bibtexparser\customization.py", line 508, in convert_to_unicode record[val] = latex_to_unicode(record[val]) File "c:\python38\lib\site-packages\bibtexparser\latexenc.py", line 67, in latex_to_unicode string = _replace_all_latex(string, itertools.chain( File "c:\python38\lib\site-packages\bibtexparser\latexenc.py", line 55, in _replace_all_latex string = _replace_latex(string, l.rstrip(), u) File "c:\python38\lib\site-packages\bibtexparser\latexenc.py", line 37, in _replace_latex if unicodedata.combining(unicod): TypeError: combining() argument must be a unicode character, not str

@brimwats1
Copy link
Author

I think this was related to accidently exporting my whole library from zotero. I exported just a limited number of pubs and then renamed it mypubs.bib and moved it to the folder where academic was

leaving this open so y'all can see it but feel free to close

@tormodb
Copy link

tormodb commented Dec 23, 2019

Thanks for this extremely useful tool!

However, I am also experiencing this issue. If there is a limit related to the maximum number of entries allowed by the script In each bibtex file, it would be good to mention this in instructions. My file contained about 50 entries, and I still had to split the file in four. The error message is also kind of cryptic (at least to me with little experience in programming) so some mention of this in the user-guide would have been helpful.

@gcushen
Copy link
Collaborator

gcushen commented Dec 23, 2019

The issue appears to be related to either the Bibtexparser project (see sciunto-org/python-bibtexparser#187 ) or a non-standard BibTeX file.

Academic does not currently specify a minimum version of Bibtexparser, so manually updating it to latest may help: pip3 install -U bibtexparser.

gcushen added a commit that referenced this issue Dec 23, 2019
May help prevent reports of further issues similar to #54
@urskalbitzer
Copy link

Experienced the same issue with Zotero and apparently same reason as @brimwats
I selected all the publications that I wanted to export and then used 'file' -> 'Export Library'. However, this way, I accidentally exported my entire library. Instead I had to right-click on the selected publications and then use 'Export Items'.

Hope this helps in case anybody encounters the issue.

@joelostblom
Copy link

Adding another note that this did not work when I accidentally exported my entire library, but it did work when just exporting a few publications. Note that if you right click the premade "My publications" item in the left side panel, the only export option is for the entire library. You need to create a new collections and copy over your publication there before exporting only that collection via right click.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants