How to merge rows in OpenRefine

后端 未结 5 1258
予麋鹿
予麋鹿 2021-01-26 10:12

How to merge rows based on some ID field?

Original Table                   New Table

ID   | Field1 | Field2       ID     | Field1 | Field2
-----|------- |------         


        
5条回答
  •  一生所求
    2021-01-26 10:23

    It's not OpenRefine but I think it's a really good tool for a OpenRefine user. You could run this Miller (https://github.com/johnkerl/miller) command

    mlr --csv reshape -r "Field" -o item,value \
    then filter -x -S '$value==""' \
    then reshape -s item,value input.csv
    

    to have

    ID,Field1,Field2
    A,5,10
    B,1,3
    C,4,150
    

    First I create a tidy version of the data (https://vita.had.co.nz/papers/tidy-data.pdf), and than I transform again it from long to wide format

提交回复
热议问题