【问题标题】:Import columns to existing OpenRefine project将列导入现有 OpenRefine 项目
【发布时间】:2015-12-09 08:30:03
【问题描述】:

如何将外部 .csv 文件中的列添加到现有项目?

我试图在网上找到解决方案,但没有成功。

【问题讨论】:

    标签: openrefine import-from-csv


    【解决方案1】:

    使用您提供的文件,我在不到一分钟的时间内完成了此操作。

    我有一个项目,只有一列:

    如果您了解一点 Python,请尝试 Jython。 Edit Column > Add column based on this column 并选择 Language : Jython 如下:

    import csv 
    #we are going to use DictReader to transform our imported rows into dict, 
    #so we can latter just refer to the column we want by its key i.e header
    rows = csv.DictReader(open('/home/yourusername/Downloads/example.csv'), delimiter=",")  
    for row in rows:
            return row['Comprar'] #'comprar' is the header of the column i want
    

    【讨论】:

    • 感谢您的回复,但我无法让它工作。您如何调整该代码以从文件dl.dropboxusercontent.com/u/19563431/example.csv 中提取列“Comprar”?谢谢。
    • 所以你的线路应该是rows = csv.DictReader(open('C:\ where\your file\is\ example.csv'), delimiter=",") 。只需搜索如何在 Windows 上用 Python 打开文件。你的问题很容易解决。
    猜你喜欢
    • 2013-10-14
    • 2012-07-09
    • 1970-01-01
    • 2012-09-10
    • 2016-12-06
    • 2017-06-25
    • 2013-12-20
    • 2010-11-18
    • 2018-07-12
    相关资源
    最近更新 更多