我在Google精简版中有以下逗号分隔的CSV文件:
如何使用Jython或GREL将column1中的值填充为:
我试过了:
if value is None:
return row["record"]["cells"]["column1"]["value"][0]
else:
return value
有什么建议吗? 谢谢
答案 0 :(得分:1)
您的示例中棘手的部分是记录ID 1,因为您在同一记录中的column1中有两个不同的值。
所以要完成这个,你必须
ID
和column1
字段来创建新索引(请参阅
tutorial)row.record.cells["Column1"].value[0]
填写(请参阅
tutorial)我已经成功完成了6个步骤,这是应用于项目的JSON代码:
[
{
"op": "core/column-addition",
"description": "Create column ID2 at index 2 based on column Column1 using expression grel:cells['ID'].value+value",
"engineConfig": {
"facets": [],
"mode": "record-based"
},
"newColumnName": "ID2",
"columnInsertIndex": 2,
"baseColumnName": "Column1",
"expression": "grel:cells['ID'].value+value",
"onError": "set-to-blank"
},
{
"op": "core/text-transform",
"description": "Text transform on cells in column ID2 using expression grel:cells['ID'].value",
"engineConfig": {
"facets": [
{
"invert": false,
"expression": "isBlank(value)",
"selectError": false,
"omitError": false,
"selectBlank": false,
"name": "ID",
"omitBlank": false,
"columnName": "ID",
"type": "list",
"selection": [
{
"v": {
"v": false,
"l": "false"
}
}
]
},
{
"invert": false,
"expression": "isBlank(value)",
"selectError": false,
"omitError": false,
"selectBlank": false,
"name": "Column1",
"omitBlank": false,
"columnName": "Column1",
"type": "list",
"selection": [
{
"v": {
"v": true,
"l": "true"
}
}
]
}
],
"mode": "row-based"
},
"columnName": "ID2",
"expression": "grel:cells['ID'].value",
"onError": "keep-original",
"repeat": false,
"repeatCount": 10
},
{
"op": "core/text-transform",
"description": "Text transform on cells in column ID2 using expression grel:cells['Column1'].value",
"engineConfig": {
"facets": [
{
"invert": true,
"expression": "value",
"selectError": false,
"omitError": false,
"selectBlank": true,
"name": "Column1",
"omitBlank": false,
"columnName": "Column1",
"type": "list",
"selection": [
{
"v": {
"v": " ",
"l": " "
}
}
]
},
{
"invert": false,
"expression": "isBlank(value)",
"selectError": false,
"omitError": false,
"selectBlank": false,
"name": "ID",
"omitBlank": false,
"columnName": "ID",
"type": "list",
"selection": [
{
"v": {
"v": true,
"l": "true"
}
}
]
}
],
"mode": "row-based"
},
"columnName": "ID2",
"expression": "grel:cells['Column1'].value",
"onError": "keep-original",
"repeat": false,
"repeatCount": 10
},
{
"op": "core/column-move",
"description": "Move column ID2 to position 0",
"columnName": "ID2",
"index": 0
},
{
"op": "core/text-transform",
"description": "Text transform on cells in column Column1 using expression grel:row.record.cells[\"Column1\"].value[0]",
"engineConfig": {
"facets": [],
"mode": "record-based"
},
"columnName": "Column1",
"expression": "grel:row.record.cells[\"Column1\"].value[0]",
"onError": "keep-original",
"repeat": false,
"repeatCount": 10
},
{
"op": "core/column-removal",
"description": "Remove column ID2",
"columnName": "ID2"
}
]