APK errors

A WhatsApp chat breaks ə in Excel

A chat exported from an Azerbaijani phone is a line like this: 12.10.2026, 14:05 - Əli: salam. The file is UTF-8. When you double-click it, Excel opens it with the system table. That table has no ə, so the letter becomes ? or another mark.

Do not open the .txt straight in Excel. Write a CSV first and put a BOM at the start.

  • Export the chat without media. Read the .txt that comes out as UTF-8.
  • Write the CSV with encoding="utf-8-sig". Excel then sees the letter ə.
  • A line looks like date - name: message. The date may use a dot or a slash. Do not turn it into a date. Keep it as text.
  • A media line and a system line have no :. The code skips them.
  • Do not drag the .txt into Excel. The letter breaks there.
from pathlib import Path
import csv

text = Path("sohbet.txt").read_text(encoding="utf-8")
rows = []
for line in text.splitlines():
    if " - " not in line or ": " not in line:
        continue
    left, message = line.split(": ", 1)
    when, name = left.split(" - ", 1)
    rows.append((when, name, message))

with open("sohbet.csv", "w", newline="", encoding="utf-8-sig") as fayl:
    writer = csv.writer(fayl)
    writer.writerow(["tarix", "ad", "mesaj"])
    writer.writerows(rows)

Related guides