Git Product home page Git Product logo

c2z's People

Contributors

oeysan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

rnaimehaom

c2z's Issues

Zotero Groups export local file?

Hi

This package looks great for accessing Zotero.

But I am looking for a way to access Group libraries for essentially downloading them in a format, which I can use in further analysis - is this possible? I couldn't figure it out yet.

Thanks,

Rainer

add items

Hi
Apologies if I'm missing something, I'm trying to add items to Zotero via a tibble of items. I've checked the item structure in c2z, and mutated my tibble (from openalex, using openalexr package) to match minus the Zotero metadata fields (e.g., ID).
There's no obvious error in the c2z::ZoteroPost log.
I can provide a reprex issue, but realise this is unlikely to be priority (and thanks for creating and sharing the package).

group_library <- Zotero(user = F, id = group_id, library = TRUE, silent = TRUE, index = F)
target_collection <- group_lib$collections$key[group_lib$collections$name == "reading"]

new_collect <- Zotero(
  zotero = group_lib,
  collection.names = c(paste0("priority_", Sys.Date())),
  library = T,
  create = T 
) 

new_collect$collections <- new_collect$collections %>%
  dplyr::mutate(parentCollection = dplyr::case_when(name == paste0("priority_", Sys.Date()) ~ target_collection,
                                                    .default = parentCollection))
  
c2z::ZoteroPost(
  new_collect,
  post.collections = T
)


# Openalex inherits MAG I think, so in theory https://github.com/zotero/translators/blob/master/Microsoft%20Academic.js should give some guidance 
items <- literature_priority %>%
    unnest_wider(col = c(author, concepts), names_sep = "_") %>%
      rowwise() %>%
    mutate(
        creators = list( #needs to be a tibble, creatorType, firstName, lastName 
            data.frame(
                creatorType = "author",
                firstName = sapply(author_au_display_name, function(names) sub(" .*", "", names)),
                lastName = sapply(author_au_display_name, function(names) sub(".* ", "", names))
            )
        ),
        tags = list( #needs to be tag, type (set type to 1 for them all)
            data.frame(
                tag = concepts_display_name,
                type = 1
            )
        )) %>%
  transmute(title = display_name,
         abstractNote = ab, 
         date = publication_date,
         rights = license, 
         url = ifelse(!is.na(oa_url), oa_url, url),
         language = language,
         DOI = doi,
         extra = paste0("grants:", grants, "\n",
               "cited_by_count:",  cited_by_count, "\n",
               "counts_by_year:", counts_by_year, "\n",
               "referenced_works:", referenced_works, "\n",
               "related_works:", related_works, "\n",
               "is_paratext:", is_paratext, "\n",
               "is_retracted:", is_retracted, "\n", collapse = "\n"),
         pages = paste0(first_page, "-", last_page),
         numPages = as.numeric(last_page) - as.numeric(first_page),
         volume = volume,
         issue = issue,
         ISSN = issn_l,
         creators = list(creators),
        itemType = case_when(type == "article" ~ "journalArticle",
                             type == "dissertation" ~ "thesis",
                             type == "book-chapter" ~ "bookSection",
                             .default = "document"),
         tags = list(tags),
         publisher = host_organization, 
         university = ifelse(type == "dissertation", host_organization, ""),
         bookTitle = ifelse(type == "book-chapter", so, ""),
         publicationTitle = ifelse(type == "article", so, ""),
        collections = c(new_collect$collection.key)
         )

post_items <-  Zotero(
  zotero = new_collect,
  items = items,
  library = T,
  create = T 
) 


zlog <- c2z::ZoteroPost(
  post_items,
  post.items = T,
  post.collections = T
)

bind_rows() error in reading library

Trying to do something with the library I previously accessed and now when I try and read it using the Zotero function I get an error... I'm not sure how to go about debugging this.

Zotero(user = F, id = group_id, silent = F, index = F, library = T)
Searching for collections 
Found 8 collections 
The Zotero list contains: 8 collections, 0 items, and 0 attachments 
Searching for all items in library 
Found 327 items 
Need 3 addtional queries to gather items 
Error in `dplyr::bind_rows()`:
! Can't combine `..1$relations$dc:replaces` <list> and `..2$relations$dc:replaces` <character>.
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/vctrs_error_ptype2>
Error in `dplyr::bind_rows()`:
! Can't combine `..1$relations$dc:replaces` <list> and `..2$relations$dc:replaces` <character>.
---
Backtrace:
    x
 1. \-c2z::Zotero(user = F, id = group_id, silent = F, index = F, library = T)
 2.   \-c2z::ZoteroLibrary(...)
 3.     \-c2z::ZoteroGet(...)
 4.       \-c2z:::AddAppend(...)
 5.         +-dplyr::distinct(dplyr::bind_rows(old.data, data))
 6.         \-dplyr::bind_rows(old.data, data)
Run rlang::last_trace(drop = FALSE) to see 10 hidden frames.
> rlang::last_trace(drop = FALSE)
<error/vctrs_error_ptype2>
Error in `dplyr::bind_rows()`:
! Can't combine `..1$relations$dc:replaces` <list> and `..2$relations$dc:replaces` <character>.
---
Backtrace:
     x
  1. +-c2z::Zotero(user = F, id = group_id, silent = F, index = F, library = T)
  2. | \-c2z::ZoteroLibrary(...)
  3. |   \-c2z::ZoteroGet(...)
  4. |     \-c2z:::AddAppend(...)
  5. |       +-dplyr::distinct(dplyr::bind_rows(old.data, data))
  6. |       \-dplyr::bind_rows(old.data, data)
  7. |         \-vctrs::vec_rbind(!!!dots, .names_to = .id, .error_call = current_env())
  8. \-vctrs (local) `<fn>`()
  9.   \-vctrs::vec_default_ptype2(...)
 10.     +-base::withRestarts(...)
 11.     | \-base (local) withOneRestart(expr, restarts[[1L]])
 12.     |   \-base (local) doWithOneRestart(return(expr), restart)
 13.     \-vctrs::stop_incompatible_type(...)
 14.       \-vctrs:::stop_incompatible(...)
 15.         \-vctrs:::stop_vctrs(...)
 16.           \-rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.