Import columns to existing OpenRefine project

2019-06-08 20:05发布

问题:

How do I add a column from an external .csv file to an existing project?

I tried to find the solution online, but I wasn't successful.

回答1:

Using the file you provided, I did this in less than one minute.

I had a project, with one column: .

If you know a little Python, try Jython. Edit Column > Add column based on this column and chose Language : Jython like this:

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