Skip to main content

A tool to visualize vCard contacts as an interactive graph

Project description

vcard-graph

A Python tool to visualize vCard contacts as an interactive graph, showing relationships between people and organizations.

Features

  • Parse vCard files (.vcf and .vcard formats) using the vobject library
  • Extract standard vCard fields including names, emails, organizations, and relationships
  • Build a network graph showing connections between contacts
  • Visualize relationships with different colors for different relationship types (spouse, child, parent, friend, colleague, etc.)
  • Group contacts by organization
  • Generate interactive HTML visualizations using Plotly

Installation

pip install vcard-graph

For development:

pip install -e ".[dev]"

Usage

Command Line

Visualize vCard files:

# Single file
vcard-graph contacts.vcf

# Multiple files
vcard-graph contact1.vcf contact2.vcf contact3.vcf

# From a directory
vcard-graph ~/contacts/ --directory

# Specify output file
vcard-graph contacts.vcf -o my_graph.html

Python API

from pathlib import Path
from vcard_graph import VCardParser, VCardGraph

# Parse vCard files
parser = VCardParser()
parser.parse_file(Path("contacts.vcf"))

# Or parse a directory
parser.parse_directory(Path("~/contacts"))

# Build and visualize the graph
graph = VCardGraph()
graph.build_from_parser(parser)
graph.visualize("output.html")

# Get statistics
stats = graph.get_stats()
print(f"People: {stats['people']}")
print(f"Organizations: {stats['organizations']}")
print(f"Relationships: {stats['relationships']}")

vCard Relationship Support

The tool supports both standard vCard relationships and Apple-specific relationship fields.

Standard RELATED Field (RFC 6350)

The standard RELATED field from vCard 4.0 with TYPE parameter:

RELATED;TYPE=spouse:bob@example.com
RELATED;TYPE=child:alice@example.com
RELATED;TYPE=parent:carol@example.com
RELATED;TYPE=friend:dave@example.com
RELATED;TYPE=colleague:eve@example.com

Apple X-ABRELATEDNAMES

Apple Contacts uses X-ABRELATEDNAMES with item grouping and X-ABLabel:

item1.X-ABRELATEDNAMES:Bob Smith
item1.X-ABLabel:_$!<Friend>!$_
item2.X-ABRELATEDNAMES:Carol Johnson
item2.X-ABLabel:_$!<Mother>!$_
item3.X-ABRELATEDNAMES:Dave Wilson
item3.X-ABLabel:Custom Relation

Apple uses the format _$!<Type>!$_ for standard relationship types and plain text for custom labels.

Supported Relationship Types

All relationship types are visualized with different colors in the graph:

  • Family: spouse, partner, child, parent, mother, father, sibling, brother, sister
  • Social: friend
  • Professional: colleague, assistant, manager
  • Other: related (default), custom labels

Each relationship type is visualized with a different color in the graph.

Graph Visualization

The interactive graph shows:

  • People as colored circles (color varies by category)
  • Organizations as red squares
  • Relationships as colored lines (color varies by relationship type)
  • Hover over nodes to see details (name, email, organization, categories)
  • Legend showing relationship types and categories

Category Colors

Contacts are automatically grouped and color-coded by their vCard CATEGORIES field. Each unique category is assigned a distinct color from a diverse color palette. The visualization:

  • Groups contacts spatially by their primary category
  • Colors each category distinctly for easy visual identification
  • Shows "Uncategorized" in gray for contacts without categories
  • Displays all categories in the legend

System categories like "Starred" and "MyContacts" are automatically filtered out.

To assign categories to contacts, add the CATEGORIES field to your vCard:

CATEGORIES:Family,VIP

Any category name you use will automatically get a color assigned!

Development

Run tests:

pytest

Format code:

ruff format .

Check code style:

ruff check .

Type checking:

mypy src

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcard_graph-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcard_graph-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file vcard_graph-0.1.0.tar.gz.

File metadata

  • Download URL: vcard_graph-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for vcard_graph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f5e72529b31a17f7fefcb331709ad6d83e0f4d920b46ddba3e245e56b3e91b1c
MD5 edf078a9062a5b4c4369037d84aa2cea
BLAKE2b-256 9a0928c0056a54cb848a6a4188d82cd57eebb8eced2325fb9ff52f0037d6a985

See more details on using hashes here.

File details

Details for the file vcard_graph-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vcard_graph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for vcard_graph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57a90d09a0bfb0951ae5da54c9d9136ac5908e4f366554980c172d70ec8e89b5
MD5 b028ca961c9918128ea0769625030a1f
BLAKE2b-256 2d245f390c56d6eca021aa04f0d7ec8226a1a56ad7d9478a8d3884a3f55a3f64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page