2016-07-27 6 views
0

여러 연락처에 vCard를 구문 분석하는 방법이 얻을 : 내가내가 성공적으로 분석 한 vCard를 통해 연락처를 가져하려고

vcards = vobject.readOne(in_data) 

: 나는 vCard를 읽고 vobject을 사용했다

BEGIN:VCARD 
VERSION:3.0 
FN:Harsimer Kaur 
N:Kaur;Harsimer;;; 
X-EVOLUTION-FILE-AS:Kaur\, Harsimer 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5743EEB900000000 
REV:2016-05-24T06:03:37Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Kaur Ramanpreet 
N:Ramanpreet;Kaur;;; 
X-EVOLUTION-FILE-AS:Ramanpreet\, Kaur 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5742DAB000000000 
REV:2016-05-23T10:25:52Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Gunjan Sharma 
N:Sharma;Gunjan;;; 
X-EVOLUTION-FILE-AS:Sharma\, Gunjan 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-57236BA000000000 
REV:2016-04-29T14:11:44Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Pawanjeet Kaur-PHP 
N:Kaur-PHP;Pawanjeet;;; 
X-EVOLUTION-FILE-AS:Kaur-PHP\, Pawanjeet 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5717547800000000 
REV:2016-04-20T10:05:44Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Bansal Nancy 
N:Nancy;Bansal;;; 
X-EVOLUTION-FILE-AS:Nancy\, Bansal 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-57025A5300000000 
REV:2016-04-04T12:13:07Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Vivek Rana 
N:Rana;Vivek;;; 
X-EVOLUTION-FILE-AS:Rana\, Vivek 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-56CAB5EF00000000 
REV:2016-02-22T07:17:03Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Kulvir Kaur 
N:Kaur;Kulvir;;; 
X-EVOLUTION-FILE-AS:Kaur\, Kulvir 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-56728A8C00000000 
REV:2015-12-17T10:12:28Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Seema PHP 
N:PHP;Seema;;; 
X-EVOLUTION-FILE-AS:PHP\, Seema 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-566ACFEC00000000 
REV:2015-12-11T13:30:20Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Seasia IT Team 
N:Team;Seasia;IT;; 
X-EVOLUTION-FILE-AS:Team\, Seasia 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5668F04700000005 
REV:2015-12-10T03:23:51Z(10) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Saumya PHP 
N:PHP;Saumya;;; 
X-EVOLUTION-FILE-AS:PHP\, Saumya 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5668F03100000004 
REV:2015-12-10T03:23:29Z(8) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Gaurav PHP 
N:PHP;Gaurav;;; 
X-EVOLUTION-FILE-AS:PHP\, Gaurav 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5668F01F00000003 
REV:2015-12-10T03:23:11Z(6) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Rishav Sharma PHP 
N:PHP;Rishav;Sharma;; 
X-EVOLUTION-FILE-AS:PHP\, Rishav 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5668F00B00000002 
REV:2015-12-10T03:22:51Z(4) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Jatinder Bawa 
N:Bawa;Jatinder;;; 
X-EVOLUTION-FILE-AS:Bawa\, Jatinder 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5668EFEC00000001 
REV:2015-12-10T03:22:20Z(2) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Gurpreet Singh-PM 
N:Singh-PM;Gurpreet;;; 
X-EVOLUTION-FILE-AS:Singh-PM\, Gurpreet 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-5668EFCE00000000 
REV:2015-12-10T03:21:50Z(0) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Narinder Singh 
N:Singh;Narinder;;; 
X-EVOLUTION-FILE-AS:Singh\, Narinder 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-565E7BBA00000002 
REV:2015-12-02T05:03:54Z(4) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Kuldeep Raj 
N:Raj;Kuldeep;;; 
X-EVOLUTION-FILE-AS:Raj\, Kuldeep 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-565E7BA700000001 
REV:2015-12-02T05:03:35Z(2) 
END:VCARD 

BEGIN:VCARD 
VERSION:3.0 
FN:Devi Lal Verma 
N:Verma;Devi;Lal;; 
X-EVOLUTION-FILE-AS:Verma\, Devi 
EMAIL;TYPE=OTHER:[email protected] 
UID:pas-id-565E7B9D00000000 
REV:2015-12-02T05:03:25Z(0) 
END:VCARD 

cmatskas 자바 스크립트 플러그인을 사용하여 파일 업로드 및 읽기 :

여러 개의 연락처 정보 (예 : 여러 개의 시작 및 종료 태그가있는 카드)로 vcard를 구문 분석하려면 어떻게해야합니까?

답변

1

vobject를 사용하면 readComponents 기능을 사용하여 vcard 파일의 모든 구성 요소를 가져올 수 있습니다.

import vobject 
import codecs 

obj = vobject.readComponents(codecs.open(path, encoding='utf-8').read()) 
contacts = [contact for contact in obj] 

readComponents 당신을 통해 반복하고 모든 연락처를 검색 할 수있는 발전기를 돌려 : 나는 path에 저장 거기에 여러 연락처와 vCard 파일이있는 경우 예를 들어, 다음 내가 가진 모든 연락처를 반환 할 수 있습니다.