RDF extra field

edited May 1, 2020
Hello
I downloaded beetbibtex in order to make an export for French national archives HAL.
Finally I deleted it but since then I have in my extra fields some notes like Translatorsn_ XXXXX or "Reporter: journal title" and Numebr: journal issue" or "Type" etc.
I deleted these informations manually but they came back with synchronization.
How can I remove these notes knowing that I can't delete the extra field in its total because there is information I want to keep?
I'm working in a group library, anyone has betterbibtex no more
Thank you very much, best regards
Gianna
«1
  • edited April 16, 2020
    I'm having a hard time following exactly what you want to do and what is happening. Could you explain again in more detail?

    Please feel free to write in French if that is easier.
  • I'm sorry, I'll try to be clearer.
    J'ai utilisé betterbibtex to make a real zotero export for a French base
    I finally uninstalled it
    But now our shared library has in the extra field a series of notes like "Reporter and the title of the magazine" or "Number and the number of the magazine" Translators a following number" etc.
    We have uninstalled and reinstalled everything again, but these notes remain.
    We have manually deleted note by note (8000 records ..) but as soon as the synchronization is done the notes are back.
    I can't delete the extra field altogether because there's more information I'd like to keep
    How do i clean Zotero's files permanently?
  • exemple: Translators: _:n3813 Translators: _:n38698
    Number: 46 Reporter: CrystEngComm
    Number: 6
    Reporter: Climate Dynamics
    Artists: _:n7784
    Artists: _:n64136
  • Merci beaucoup!
  • Oh, I see. Okay, do you have a list all of the (untranslated if not English) labels (not the contents, just the labels) in Extra that you would like delete?
  • No, but i can do it
  • If you can do that, I can write you a Simple bit of code that you can run to clear out these data quickly.
  • thnk you! I did:
    Series Title:
    "Directors: _:
    Directors: _:
    Producers: _:
    insu-01290806"
    Issue:
    Number:
    Reporter:
    Translators: _:n2068
    Translators: _:n24268
    Version Number:
    Artists: _:
    Book Authors: _:
    Reporter:
    Publication Title:
    Code:
    Publischer:
    Place:

    I have a question
    Sometimes I would like to delete the label and content of this label together, but not all the extra information
    For example :
    Extra : Number: 1
    Reporter: Current Anthropology
    https://hal.archives-ouvertes.fr/hal-01462313
    I would like to delete :
    “Number: 1
    Reporter: Current Anthropology”
    But I want keep : https://hal.archives-ouvertes.fr/hal-01462313
    Is it possible?
    Many many thanks
  • Yes, that’s possible. I will write some code to do that for you.

    Note though, that for links like that, it would be better to attach them to the item as an attached link, rather than storing them in Extra.
  • THANK YOU!
    yes, I will follow your suggestion.
    Many thanks, have a nice day
    Gianna
  • Dear bwiernik
    I think writing the code takes you a long time...
    I'm very sorry.
    Gianna
  • Can you select a few items with these data (and also at least one with a link you want to keep), right click and export to CSL JSON. Then copy the text in the exported file, post to https://hastebin.com and post a link here?
  • Also, what is "insu-01290806"? Is it just that specific text or something more general? Or can you just delete those manually?

  • var fieldName = "extra";
    var pattern = /^((Directors)|(Producers)|(Issue)|(Number)|(Reporter)|(Translators)|(Version Number)|(Artists)|(Book Authors)|(Reporter)|(Publication Title)|(Code)|(Publisher)|(Place)):.*$(\n)?/;
    var replace = "";

    var fieldID = Zotero.ItemFields.getID(fieldName);
    var s = new Zotero.Search();
    s.libraryID = Zotero.Libraries.userLibraryID;
    s.addCondition(fieldName, 'contains', 'Directors');
    s.addCondition(fieldName, 'contains', 'Producers');
    s.addCondition(fieldName, 'contains', 'Issue');
    s.addCondition(fieldName, 'contains', 'Number');
    s.addCondition(fieldName, 'contains', 'Reporter');
    s.addCondition(fieldName, 'contains', 'Translators');
    s.addCondition(fieldName, 'contains', 'Version Number');
    s.addCondition(fieldName, 'contains', 'Artists');
    s.addCondition(fieldName, 'contains', 'Book Authors');
    s.addCondition(fieldName, 'contains', 'Reporter');
    s.addCondition(fieldName, 'contains', 'Publication Title');
    s.addCondition(fieldName, 'contains', 'Code');
    s.addCondition(fieldName, 'contains', 'Publisher');
    s.addCondition(fieldName, 'contains', 'Place');
    s.addCondition('joinMode', 'any');
    var ids = await s.search();
    if (!ids.length) {
    return "No items found";
    }
    await Zotero.DB.executeTransaction(async function () {
    for (let id of ids) {
    let item = await Zotero.Items.getAsync(id);
    let mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
    var oldValue = item.getField(mappedFieldID ? mappedFieldID : fieldID);
    var newValue = oldValue.replace(pattern, '');
    item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);
    await item.save();
    }
    });
    return ids.length + " item(s) updated";



    This should work, but I haven't tested it. If you send some example items like I asked above, I can test it out and make it work.

    In Zotero, click Tools -> Developer -> Run Javascript, paste the code there, check the "Run as async function" box, and click Run. Before doing this, be sure to make a backup of your database just in case: https://www.zotero.org/support/zotero_data#backing_up_your_zotero_data

  • edited April 21, 2020
    Hastebin save is not working[

    [code removed — D.S]

    , I past the items here, i would keep "https://hal.archives-ouvertes.fr/hal-02458658"
    :
  • Also, what is "insu-01290806"? Is it just that specific text or something more general? Or can you just delete those manually?

    insu plus the code is an import in extra by zotero connector, the code change by item.
    Yes I can delete manually
  • I tested the code, I'm sorry but it is not working. I don't understand why now Zotero has been importing this data in extra.
    I delete plugin (chrome and mozilla) and update it but anything is chancing.
    Thank you very much for your help
    Gianna
  • I find!: https://pastie.io/tznrbc.json
    Encore merci beaucoup
    Gianna
  • edited April 22, 2020
    I don't think that this is necessarily anything to do BetterBibTeX. Zotero's import behavior recently updated to save item data in Extra for fields where the item doesn't have proper fields, rather than just discarding it (in many cases, this is important, such as a DOI for a book chapter). It's possible that the site you are importing from has a bunch of low-quality metadata that Zotero is detecting. If you know what website you imported these items from, you can import them again and check. If you find a site serving bad data, post a URL in a new thread with details.

    If you imported these items by importing a .bib file, can you share that file?
  • Yes, or there is a problem with translators, because in this case Zotero saves item data in Extra and the same informations in the proper fields.
    Our propres field are in French , the data in extra in English.
    The problem is that many sites do it for our Zotero, even when they work well.
  • Okay, am I correct in saying that you would like any line of the form:
    variable: value to be deleted? That would retain any URLs you have stored in Extra.

    If so, then this code will do that:

    var fieldName = "extra";

    var fieldID = Zotero.ItemFields.getID(fieldName);
    var s = new Zotero.Search();
    s.libraryID = Zotero.Libraries.userLibraryID;
    s.addCondition(fieldName, 'contains', ': ');
    s.addCondition('joinMode', 'any');
    var ids = await s.search();
    if (!ids.length) {
    return "No items found";
    }
    await Zotero.DB.executeTransaction(async function () {
    for (let id of ids) {
    let item = await Zotero.Items.getAsync(id);
    let mappedFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(item.itemTypeID, fieldName);
    var oldValue = item.getField(mappedFieldID ? mappedFieldID : fieldID);
    var newValue = oldValue.replace(/^([A-Za-z \-]+)(:\s+.+)/gm, '');
    item.setField(mappedFieldID ? mappedFieldID : fieldID, newValue);
    await item.save();
    }
    });
    return ids.length + " item(s) updated";


    Note that that in some cases, these are legitimate data that you would want to keep. If you are okay with that risk, this will remove all of these data quickly.
  • Thank you, I test tomorrow now my colleague is working with zotero library.
    I will sent you a feedback as soon as possible.
    Many thanks!
  • This is indeed not something BBT does.
  • Hi
    Thank you very much the tool works very well but there is a problem.
    I exported the items in RDF format for groups of extras to clean.
    Everything was clean.
    Not easy to clean all 8055 records at once
    I exported the RDF items again to import it into the good library
    Unfortunately the import added all the fields that I had deleted
    I gather it depends on the RDF format
    The export in csl jason does not export the tags
    BibText puts the extra field in notes
    I'm in stanby ...
    I agree Emilianonoehey it's not a BBT problem, but a RDF format problem.
  • I'm not following at all what you are just saying that you did. Why are you exporting something? That isn't necessary at all. Just run the script I posted by clicking Tools → Developer → Run JavaScript
  • Unfortunately not because in the meantime we have updated 3000 items that contain new extra fields to keep.
    In this period of lockdown, we have to feed the library quickly because it feeds the website
  • I’m sorry, but what? I can’t tell if something is still wrong, if you need help with something?

    You should _not_ be continuously exporting and re-importing things to try to troubleshoot your library. That isn’t going to fix anything and is going to make more of a mess.

    Are you still trying to fix a problem or no?
  • Yes, I m still trying to fix the problem.
  • I really need you to describe in detail exactly what you are doing and what happens. Have you run the script I gave you to clear out the data in Extra?
  • Yes, and it worked very well, but now I have an important kind of extra to keep and eliminate.
    For example in the same extra field now contains:
    translation espagnole de La littérature, pour quoi faire?, Paris, Collège de France / Fayard, 2007
    or:
    PMID: 29054166. PMCID: PMC5667889
    or
    postprint : https://hal.archives-ouvertes.fr/hal-00207465/document
    and many others.
    I can do a list
    We are 4 to work in this library, I asked the group to stop for this three-day holiday to try to fix the problem
Sign In or Register to comment.