Skip to content

Added a script that can conver vcf contacts file to excle, which then you can edit as you wish to edit in excle#547

Open
shaun2006 wants to merge 1 commit intowasmerio:mainfrom
shaun2006:main
Open

Added a script that can conver vcf contacts file to excle, which then you can edit as you wish to edit in excle#547
shaun2006 wants to merge 1 commit intowasmerio:mainfrom
shaun2006:main

Conversation

@shaun2006
Copy link

PR Title

Add VCF to Excel Converter Script with CLI Support and Documentation

Summary

This PR adds a Python script that converts VCF (vCard) files to Excel (.xlsx) format and includes command-line argument support along with a README file for usage instructions.

Description

This pull request introduces a new utility script vcf_to_excel.py that parses VCF files and converts contact data into an Excel spreadsheet.

The script supports command-line usage with optional output file naming using the -o flag. If no output file is provided, the script automatically generates an Excel file with the same base name as the input VCF file.

Additionally, a README.md file has been added to document installation steps, usage instructions, and extracted fields.

The goal of this PR is to provide a simple, clean, and user-friendly solution for converting contact files into a structured Excel format.

The changes are as follows:

  • Added vcf_to_excel.py script
  • Implemented command-line argument support using argparse
  • Added automatic output file naming
  • Added README.md with usage and setup instructions
  • Structured contact parsing for names, phone numbers, emails, organization, and address

Checks

in the repository

  • Made no changes that degrade the functioning of the repository
  • Gave each commit a better title (clear and descriptive)

in the PR

  • Followed the format of the pull_request_template
  • Made the Pull Request at a small and focused level
  • Tested the changes made

Thank You,

[Shaun Babar]


for line in file:
line = line.strip()

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for line in file:
            line = line.strip()

            match line:
                case line.startswith("BEGIN:VCARD"):
                    contact = {}
                case line.startswith("FN:"):
                    contact["Full Name"] = line.replace("FN:", "")
                case line.startswith("TEL"):
                    phone = line.split(":")[-1]
                    contact.setdefault("Phone Numbers", []).append(phone)
                case line.startswith("EMAIL"):
                    email = line.split(":")[-1]
                    contact.setdefault("Emails", []).append(email)
                case line.startswith("ORG:"):
                    contact["Organization"] = line.replace("ORG:", "")
                case line.startswith("ADR"):
                    address = line.split(":")[-1].replace(";", " ")
                    contact["Address"] = address 
                case line.startswith("END:VCARD"):
                    contact["Phone Numbers"] = ", ".join(contact.get("Phone Numbers", []))
                    contact["Emails"] = ", ".join(contact.get("Emails", []))
                    contacts.append(contact)
                case _:
                    continue

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better if you use switch-case instead of if and elifs

Copy link

@yooung1 yooung1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented a few things


for line in file:
line = line.strip()

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better if you use switch-case instead of if and elifs

df = pd.DataFrame(contacts)
df.to_excel(output_file, index=False)

print(f"✅ Conversion complete! Saved as {output_file}")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not good to use emojis in prints

print(f"Conversion complete! Saved as {output_file}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants