作者asdrt (安靜)
站內Editor
標題[vim ] 抓取固定符號內資料並刪除固定開頭資料
時間Wed May 28 14:51:50 2014
example :
{
description : "",
id : "123239293019203dksodsdajsd",
aaa : true,
bbb : true,
ccc : false,
ddd : true,
label : "彰化市",
lookAt : "none"
}
,
{
description : "",
id : "0d5e20ea-d6be-11e3-b258-835bdbdbe6c8",
aaa : false,
bbb : true,
ccc : true,
ddd : false,
label : "新化市",
lookAt : {
altitude : 3941.32,
lat : 24.06294152443659,
lng : 120.5843182509465,
zoom : 14
}
}
,
以下重複 loop ..
有的有 lookat 後面那些資訊 有些沒有 ~
我想抓取
{} 裡面的資訊
但是只想要抓取
id &
lable 這兩行
變成像是 excel
id lable
123123123112 彰化市
123123990123 某某某
..
.
等
這樣有可能可以做到嗎?
因為不是固定的行距範圍內抓取 所以有點困擾
還是說可以用其他編輯軟體像是notepad++ or Ultraeditor ?
感謝幫忙
--
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.120.76.145
※ 文章網址: http://www.ptt.cc/bbs/Editor/M.1401259913.A.988.html
※ 編輯: asdrt (59.120.76.145), 05/28/2014 14:56:09
※ 編輯: asdrt (59.120.76.145), 05/28/2014 15:30:44
→ asdrt:thanks a lot 05/28 17:06
→ hSATAC:看起來像個 json 可以直接吃進來處理 05/28 20:49
→ asdrt:痾 對 他就是一個json @@ 05/28 22:04
推 fjm31714:vim :%s/^\(id\|label\)\@!.*\n//g 05/29 00:52
推 darkgerm:是 json 的話寫程式爬會比較快 05/29 01:04
→ darkgerm: 簡單 05/29 01:04
→ shaform:vim :python (誤 06/01 22:48