[Python] How to Extract Contact Names and Phone Numbers in Order from WhatsApp Chat Export...

Discussão em 'Python' iniciado por Stack, Fevereiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    Description: I’m trying to extract contact names and phone numbers from a WhatsApp chat export in the order they appear in the chat. The goal is to retrieve the contacts (names or numbers) as they appear before each message.

    The exported chat file includes messages along with contact names or phone numbers, and I need a way to parse this file to extract just the contact details (name/number), maintaining the sequence as it appears in the original chat.

    Requirements: Parse the WhatsApp chat export (usually a .txt file) containing the contact name or phone number preceding each message. Extract only the contact names and numbers in the order they appear in the file. Provide a Python or JavaScript solution to efficiently extract this information. Example: The chat file might look something like this:

    John Doe: Hello, how are you?
    Jane Smith: I'm good, thanks! You?
    John Doe: I'm doing well, just working.
    From this, I want to extract:


    ['John Doe', 'Jane Smith', 'John Doe']


    I need a Python or JavaScript approach to handle this extraction. Any guidance on parsing the file and extracting the contact details in the correct order would be appreciated.

    Continue reading...

Compartilhe esta Página