用vs2010 把 vcf 转成 csv,再转入Nokia

android 备份的通讯录格式是 vcf ,这种格式即使使用 Nokia 套件也无能为力(我使用 windows2008,打开直接退出。)。

用记事本打开vcf 后,发现是一种比较整齐的格式。

使用 正则表达式替换。

BEGIN\:VCARD	\{
END\:VCARD	\}
TEL\;TYPE\=CELL\;TYPE\=PREF\:{.*}	Mobile:"\1",
TEL\;TYPE\=WORK\;TYPE\=FAX\:{.*}	Fax:"\1",
TEL\;TYPE\=WORK\:{.*}	Work:"\1",
ORG\;CHARSET\=UTF\-8\:{.*}	Corp:"\1",
EMAIL\;TYPE\=PREF\;TYPE\=X\-INTERNET\:{.*}	Email:"\1",
TEL\;TYPE\=WORK\;TYPE=PREF\:{.*}	Mobile:"\1",
NOTE\;CHARSET\=UTF\-8\:{.*}	Remark:"\1",
TEL\;TYPE\=HOME\:{.*}	Home:"\1",
N\:{[^\;]*}\;{.*}	Xing:"\1",Ming:"2",
FN\:{.*}	FN:"\1",
TEL\;TYPE\=CELL\:{.*}	Mobile2:"\1",
TEL\;TYPE\=HOME\;TYPE\=PREF\:{.*}	Home:"\1",
TITLE\;CHARSET\=UTF\-8\:{.*}	Title:"\1",

然后,把内容制作成一个 Json格式。形如: [{},{}] 

在 FireBug 中执行:

var data = 把上面整理的Json 贴过来。

回车,再继续执行:

var toOne = function(r){

return "\"" + ( "" ) +"\"," +
"\"" + ( r.FN || "" ) +"\"," +
"\"\","+
"\"" + (  "" ) +"\"," +
"\"\","+
"\"" + ( r.Title || "" ) +"\"," +
"\"" + ( r.Corp || "" ) +"\"," +
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"" + ( r.Remark || "" ) +"\"," +
"\"" + ( r.Mobile || "" ) +"\"," +
"\"" + ( r.Mobile2 || "" ) +"\"," +
"\"" + ( r.Email || "" ) +"\"," +
"\"" + ( r.Fax || "" ) +"\"," +
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"" + ( r.Home || "" ) +"\"," +
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"" + ( r.Work || "" ) +"\"," +
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+
"\"\","+

"\"\","+
"\"\"" ;
}

回车再执行:

for(var i=0;i<data.length;i++){ console.log( toOne( data[i] ) ); }

在联系人里建一个联系人,导出成 csv 格式。 用 VS2010 打开VSV,把 fireBug 输出的内容贴到最下面。

保存,再用 Nokia 套件的联系人,导入。即可。

 

你可能感兴趣的:(VS2010)