-1

I have vcf file of my business contacts , I need to edit the names saved in the file contact using a code but it seems it's not working with vcf modules so , please help it's more than 3k phone number

i tried to install pyvcf ,vcf module ,and pip has upgraded also" environment "is good

1 Answers1

1
def update_vcf_contacts(input_file, output_file):
    updated_lines = []

    with open(input_file, 'r') as f:
        for line in f:
            if line.startswith('FN:'):
                # Modify the contact name here, for example, add a suffix '-Edited'
                updated_line = line.strip() + '-Edited\n'
            else:
                updated_line = line

            updated_lines.append(updated_line)

    with open(output_file, 'w') as f:
        f.writelines(updated_lines)


if __name__ == "__main__":
    input_vcf_file = "input.vcf"
    output_vcf_file = "output.vcf"

    update_vcf_contacts(input_vcf_file, output_vcf_file)
AX Maximus
  • 21
  • 2
  • thanks this code works , also i need to see the results in pc – Ahmad Nour Jul 30 '23 at 10:11
  • Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. **Would you kindly [edit] your answer to include additional details for the benefit of the community?** – Jeremy Caney Aug 05 '23 at 00:52
  • Thank you , all I want to write a script can edit and read vcf files , but finally it seems this answer doesn't fit to the business that i need , so please if there is module of vcf , help me – Ahmad Nour Aug 10 '23 at 19:18