import pandas as pd import vobject def vcf_to_csv(vcf_file, csv_file): with open(vcf_file, 'r', encoding='utf-8') as file: vcf_data = file.read() # Parse the VCF data using vobject vcf_parsed = vobject.readComponents(vcf_data) # Extract information from the VCF objects data_list = [] for vcard in vcf_parsed: name = vcard.fn.value if hasattr(vcard, 'fn') else '' email = vcard.email.value if hasattr(vcard, 'email') else '' data_list.append({'Name': name, 'Email': email}) # Create a DataFrame from the extracted data df = pd.DataFrame(data_list) # Write the DataFrame to a CSV file df.to_csv(csv_file, index=False) # Example usage vcf_to_csv('/path/to/contacts.vcf', '/path/to/contacts.csv')