从UTF
我已经尝试过使用csvtojson模块来创建GeoJSON格式的文件,但是嵌套根本无法正常工作。谁能指出我正确的方向,还是我需要编写自己的代码?
> npx csvtojson input.tsv > output.json
input.tsv
properties.labelTc properties.labelEn properties.nameTc properties.nameEn properties.zoomifyX properties.zoomifyY geometry.coordinates.1 geometry.coordinates.0 properties.urlEn properties.urlZh type
皇城 The Imperial Palace City 明故宫 Ming Palace 105513 -1863 32.038 118.815 Feature
天地壇 Altar of Heaven and Earth Guanghuamen? 105049 -1000 32.058 118.832 /%E5%A4%A9%E5%9D%9B/19964669 Feature
我想要什么
{
"properties": {
"labelTc": "皇城",
"labelEn": "The Imperial Palace City",
...
},
"geometry": {
"coordinates": [118.815, 32.038]
},
"type": "Feature"
}
我得到了:
[
{
"properties": {
"labelTc\tproperties": {
"labelEn\tproperties": {
"nameTc\tproperties": {
"nameEn\tproperties": {
"zoomifyX\tproperties": {
"zoomifyY\tgeometry": {
"coordinates": {
"1\tgeometry": {
"coordinates": {
"0\tproperties": {
"urlEn\tproperties": {
"urlZh\ttype": "??\tThe Imperial Palace City\t???\tMing Palace\t105513\t-1863\t32.038\t118.815\t\t\tFeature"
}
}
}
}
}
}
}
}
}
}
}
}
},
回答如下:由于我使用的是Windows PowerShell,默认情况下,它使用Latin-1编码的扩展名,因此我既需要为csvtojson库添加一个标志,也需要为PowerShell添加第二个标志。
npx csvtojson --delimiter=\t input.tsv > output.json -encoding utf8
从UTF
我已经尝试过使用csvtojson模块来创建GeoJSON格式的文件,但是嵌套根本无法正常工作。谁能指出我正确的方向,还是我需要编写自己的代码?
> npx csvtojson input.tsv > output.json
input.tsv
properties.labelTc properties.labelEn properties.nameTc properties.nameEn properties.zoomifyX properties.zoomifyY geometry.coordinates.1 geometry.coordinates.0 properties.urlEn properties.urlZh type
皇城 The Imperial Palace City 明故宫 Ming Palace 105513 -1863 32.038 118.815 Feature
天地壇 Altar of Heaven and Earth Guanghuamen? 105049 -1000 32.058 118.832 /%E5%A4%A9%E5%9D%9B/19964669 Feature
我想要什么
{
"properties": {
"labelTc": "皇城",
"labelEn": "The Imperial Palace City",
...
},
"geometry": {
"coordinates": [118.815, 32.038]
},
"type": "Feature"
}
我得到了:
[
{
"properties": {
"labelTc\tproperties": {
"labelEn\tproperties": {
"nameTc\tproperties": {
"nameEn\tproperties": {
"zoomifyX\tproperties": {
"zoomifyY\tgeometry": {
"coordinates": {
"1\tgeometry": {
"coordinates": {
"0\tproperties": {
"urlEn\tproperties": {
"urlZh\ttype": "??\tThe Imperial Palace City\t???\tMing Palace\t105513\t-1863\t32.038\t118.815\t\t\tFeature"
}
}
}
}
}
}
}
}
}
}
}
}
},
回答如下:由于我使用的是Windows PowerShell,默认情况下,它使用Latin-1编码的扩展名,因此我既需要为csvtojson库添加一个标志,也需要为PowerShell添加第二个标志。
npx csvtojson --delimiter=\t input.tsv > output.json -encoding utf8