Export collection in CSV format - how to get rid of superfluous columns

Hello,

I am trying to export Zotero collections in CSV format. However, I notice that the resulting file contains a lot of fields/columns that I do not need. I just want the essential information such as author names, article titles, journal titles, abstract, year, etc.

Is there anything I can do so that the exported file only contains the fields I need (apart from manually deleting the unnecessary ones)?

thank you!
  • You can edit the export translator. https://www.zotero.org/support/dev/translators

    But it might be easier to just delete the unwanted columns in excel or something similar.
  • Thanks aurimas for the quick response.

    Unfortunately I have no ability to edit the translators.

    The reason why I would prefer not to manually delete the unwanted columns is this: Suppose I exported the collection at Time 1, and manually deleted those columns. When the collection expands, and the additional items in the collection are exported at Time 2, and if I want to copy and paste those additional rows into the previous excel file, then I would have to be very careful to delete from the Time 2 file precisely the same columns that were deleted at Time 1. And then Time 3, 4, etc. Too much trouble for me.

    On second thought, I think it might be worth looking into a macro that can delete multiple columns at one go ...
  • It may be easier to edit the translator than you think.

    (1) Find the translator in your <zotero data directory>/translators. It should be named CSV.js.

    (2) Close Zotero/Firefox, make a copy of the CSV.js file, rename it to something like "CSV (custom).js".

    (3) Open the file in a proper text editor, like Notepad++

    (4) At the top of the translator, change translatorID to another value. Change the label to whatever you want it to appear as, like "CSV (custom)"

    (5) Scroll down to the section towards the top that says "var exportedFields = [" and comment out or delete the columns you don't want exported. Make sure you don't mess up any of the commas (there should be one separating all columns)

    (6) Save the file, fire up Zotero, export, enjoy, buy zuphilip (Philipp Zumstein) a beer for making this easy.
  • Thank you so much aurimas for spelling out the steps for editing the translator. I think I followed all the steps, but I got an error message while trying to export using the customized translator.

    I am suspecting that I might have messed up step (5). I am pasting below my edited part, and the original part. If you could take a quick look to see if I made any mistakes, I'd really appreciate it. Thanks a lot! (I also saw that you were one of the creators of the translator. That's so great!!)

    =================
    MINE:
    // Exported columns in order of export
    var exportedFields = [
    // "Important" metadata
    "itemType","publicationYear","creators/author","title",
    "publicationTitle",abstractNote",
    // Other common fields
    "tags/own","tags/automatic",
    ];

    -------
    ORIGINAL:
    // Exported columns in order of export
    var exportedFields = [
    // "Important" metadata
    "key","itemType","publicationYear","creators/author","title",
    "publicationTitle","ISBN","ISSN","DOI","url","abstractNote","date",
    "dateAdded","dateModified",
    // Other common fields
    "accessDate","pages","numPages","issue","volume","numberOfVolumes",
    "journalAbbreviation","shortTitle","series","seriesNumber","seriesText",
    "seriesTitle","publisher","place","language","rights","type","archive",
    "archiveLocation","libraryCatalog","callNumber","extra","notes",
    "attachments/path","attachments/url","tags/own","tags/automatic",
    // Creators
    "creators/editor","creators/seriesEditor","creators/translator",
    "creators/contributor","creators/attorneyAgent","creators/bookAuthor",
    "creators/castMember","creators/commenter","creators/composer",
    "creators/cosponsor","creators/counsel","creators/interviewer",
    "creators/producer","creators/recipient","creators/reviewedAuthor",
    "creators/scriptwriter","creators/wordsBy","creators/guest",
    // Other fields
    "number","edition","runningTime","scale","medium","artworkSize",
    "filingDate","applicationNumber","assignee","issuingAuthority","country",
    "meetingName","conferenceName","court","references","reporter",
    "legalStatus","priorityNumbers","programmingLanguage","version","system",
    "code","codeNumber","section","session","committee","history",
    "legislativeBody"
    ];
  • delete the comma at the end, i.e. after "tags/automatic"
  • Also missing quote before abstractNote
  • Thank you Adam and Aurimas. I corrected the errors and now it runs smoothly. Thank you both, and zuphilip too!
  • Hey @yinbin @aurimas @adamsmith, thanks for this informative thread on editing the zotero csv translator.

    In addition to the discussion above, I want to remove the headers and make sure that, when pasted, the references start from the first line.

    I managed to (1) edit the columns to include (as described above), (2) remove the headers by:

    a. Removing writeColumnHeaders in function exportNotes (line 109)

    Now I want to make sure it pastes to the first line, but I don't manage to make it happen. I suspect I should change something in the 'doExport' function (lines 105-120). Any suggestion how to proceed?

    I created a Gist with an overview of the edits I made for clarification: https://gist.github.com/floriandierickx/b70c26d0300f73b8b9cf0f55d4260323/revisions

    ----

    var exportNotes;
    function doExport() {
    exportNotes = Zotero.getOption("exportNotes");
    // Until we fix UTF-8xBOM export, we'll write the BOM manually
    Zotero.write("\uFEFF");
    // column header writing disabled
    // writeColumnHeaders();
    var item, line;
    while (item = Zotero.nextItem()) {
    if (item.itemType == "note" || item.itemType == "attachment") continue;
    line = '';
    for (var i=0; i<exportedFields.length; i++) {
    line += (i ? fieldDelimiter : recordDelimiter)
    + getValue(item, exportedFields[i]);
    }
    Zotero.write(line);
    }
    }
  • Thank you aurimas and others for providing the explanation fo how to customize this!

    If I include additional data "fields" with the extra field in this format:
    Design: Cross-sectional
    Sample size: 400

    Is there any way to have these broken out into separate fields/columns by the translator?

    I could use a standard set/order of "fields", so it is not critical that the "field name" can be separated out. I'm also thinking that using some delimiter other than a line break may be useful. I know I could do this in Excel after exporting, but wondering if there is some way to have it be part of the export translator.

    Thanks for any advice!
  • If you know some javascript, this would be hard. It'd be along the lines of

    case 'design':
    if (item.extra && item.extra.includes("Design:") {
    value = item.extra.match(/Design:(.+)/)[1];
    }
    break;


    And then include design in the exported fields.
    Without some coding, there's no option other than splitting up Extra in Excel.
  • I'm facing the same issue. I don't want all fields. Is this really the only way? Zotero itself by using its menus doesn't allow you to customize the number of fields you see in the created database file?

    I mean who would want zillions of fields. It is just weird a program this powerful doesn't have this feature. A side note: I asked chatGPT and it said it was possible to customize it. Maybe it was possible in older versions?

    And how do you tell zotero which translator to use after you create the new custom one? I think it wasn't mentioned here in the explanation.

    Many thanks.
  • Exporting to CSV is occasionally useful but not a major use case. Building a whole GUI around column selection (a feature that would only provide minimal time savings compared to just deleting the columns in Excel) wouldn't be a good use of developer time or GUI space.

    If you create a custom translator, you'd give it a separate title and that would be available in the export dialog after restarting Zotero. For a one-off, you can also just edit the existing CSV translator, though those changes would be overwritten after the next update of either Zotero or the CSV translator.

    And FWIW, every time someone has mentioned chatGPT in a forum post here, they had been provided completely useless and false information by the LLM. This is true in your case as well. As you can tell by the posts in this thread going almost 10 years back, this has never been possible. Please don't use chatGPT for Zotero support.


  • WOW, I didn't pay attention to the posts date. Indeed they are about 10 years old which means you are right, older versions didn't support it in the GUI. Fair enough adam, I appreciate your help. Thank you very much. I know chatGPT makes mistakes but didn't expect it this time. It sounded valid.
  • "It sounded valid." That is the primary problem with chatGPT, the Bing-chatbot and the like. "They" speak with authority but gather the information from who-knows-where. I'm seeing college essays and reports that were clearly not written by a human with imaginary journals in the reference list. And who but a bot would state that the primary cause of child drownings in residential swimming pools is exposure to acetylene gas?
  • Imaginary journals ! That's awkward and off limits. I learned my lesson. But to be fair, I asked it whether it is better to get zotero support from you or from zotero forums and it said the zotero forums ^_^

    Thanks
Sign In or Register to comment.