簡體   English   中英

CSV jekyll中的數據:如何按照“出版年份”對數據進行排序和展示

[英]CSV Data in jekyll: how to sort and display data according to "Publication year"

我正在嘗試使用一個簡單的工作流程來將我的出版物 csv 整理到我基於 jekyll 的網站中的列表中。

這是我從references.csv軟件 Mendeley 中提取的 references.csv,並使用在線轉換器從bib轉換為csv 我想把它放在我的_data文件夾中,並在 github 上托管的 jekyll 網站的頁面中制作一個出版物列表。sampe 數據如下所示:

"Item type","Authors","Title","Journal","Publication year","Volume","Issue","Pages","Publisher","Date published","ISSN","URLs","DOI","PMID","Abstract","Keywords"
"Book","Wilden H","PCI design handbook: Precast and prestressed concrete","","2017","","","","Precast/Prestressed Concrete Institute Wakefield, MA, USA","2017","","","","","",""
"Journal Article","Nanni A,Di Ludovico M,Parretti R","Shear strengthening of a PC bridge girder with NSM CFRP rectangular bars","Advances in Structural Engineering","2004","7","4","297-309","SAGE PublicationsSage UK: London, England","2004-11","1369-4332","https://journals.sagepub.com/doi/10.1260/1369433041653570;http://dx.doi.org/10.1260/1369433041653570","10.1260/1369433041653570","","trimmed down abstract","keyword 1"
"Journal Article","Di B,Wang J,Li H,Zheng J,Zheng Y,Song G","Investigation of Bonding Behavior of FRP and Steel Bars in Self-Compacting Concrete Structures Using Acoustic Emission Method","Sensors 2019, Vol. 19, Page 159","2019","19","1","159","Multidisciplinary Digital Publishing Institute","2019-01","1424-8220","http://dx.doi.org/10.3390/S19010159;https://www.ncbi.nlm.nih.gov/pubmed/30621189","10.3390/S19010159","30621189","To extend ","FRP,acoustic emission,bonding,compacting concrete,out test,pull,self"
"Journal Article","Crivelli D,Bland S","Structural health monitoring via acoustic emission","Reinforced Plastics","2016","60","6","390-392","Elsevier Ltd","2016-11","0034-3617","http://dx.doi.org/10.1016/j.repl.2015.05.004","10.1016/j.repl.2015.05.004","","Reinforced Plastics spoke to Dr Davide Crivelli from the Politecnico di Milano about new methods for detecting damage in composites.",""
"Journal Article","Tonelli D,Luchetta M,Rossi F,Migliorino P,Zonta D","Structural health monitoring based on acoustic emissions: Validation on a prestressed concrete bridge tested to failure","Sensors (Switzerland)","2020","20","24","1-20","Multidisciplinary Digital Publishing Institute","2020-12","1424-8220","http://dx.doi.org/10.3390/s20247272;https://www.ncbi.nlm.nih.gov/pubmed/33352961","10.3390/s20247272","33352961","very small abstract","AE"

現在,我想從這些數據中列出列表作為引文數據,而不會陷入_includes的復雜性。 我想在單獨的“出版物”頁面中保持簡單。

例如,我使用了以下代碼

{% assign cards = site.data.references | sort: 'Publication_year' | 'reverse' %}
{% for card in cards %}
<ul>
  <li>{{ card.Publication year }} {{ card.Title }} {{ card.Publication }} </li>
  <ul> {{ card.Authors }} {{ card.Authors }} </ul>
</ul>
{% endfor %}

在代碼中,當我將 csv 中的標題用作“年份”,然后使用sort: 'Year' | 'reverse' %進行排序時 sort: 'Year' | 'reverse' % ,它有效。 也許,對於“雙詞”標題有不同的寫法,因為我認為card.Publication year不起作用。 我在這上面花了很多時間,我想我只需要使用一次代碼,然后只使用 csv 文件。

output 我打算只從Item type中選擇Journal Article ,並准備一個包含以下信息的列表,項目如下所示:

  • [出版年份][標題][期刊]
    • [作者]

    另外,我嘗試將其中一個項目中的文本斜體化,它應該像{{ __card.Publication year__ }}一樣工作,但事實並非如此。 我還在某處讀到 csv 編碼由於某些 BOM 或 UTF-8 某些編碼而不允許提取第一列。 但我想使用項目類型進行過濾。

    ps 我試圖與另一個標題與此相同的簡化代碼妥協,但谷歌學者導出 csv 有; 作為分隔符並在使用card.Authors時無法調用數據。

    抱歉,我對此一點都不熟悉,而且我正在努力使用這種語法。 但是,我預見到如果代碼有效,它會讓我的生活更輕松。 我將衷心感謝您的幫助。 對於在解釋問題時缺乏適當的行話,我深表歉意。

    先感謝您。

    我試圖在網站上顯示 csv 數據文件中的數據,但缺少一些值。 我想不出解決辦法

    您走在正確的軌道上,但您錯誤地引用了 CSV 文件列。 由於“出版年份”是一個雙詞標題,您需要使用下划線而不是空格來引用它。

    嘗試更改此行:

    {% assign cards = site.data.references | sort: 'Publication_year' | 'reverse' %}
    

    您可以使用sort_by而不是sort並提供“Publication_year”作為參數。

     {% assign cards = site.data.references | sort_by: 'Publication_year' | reverse %}
    

    在 for 循環中引用列時,還應該使用下划線:

    <li>{{ card.Publication_year }} {{ card.Title }} {{ card.Journal }} </li>
    

    暫無
    暫無

    聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

     
    粵ICP備18138465號  © 2020-2024 STACKOOM.COM