[Python] Problem with umlauts when writing with Python and opening with Excel?

Discussão em 'Python' iniciado por Stack, Junho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I am writing some content with umlauts in it using the following code:

    import csv
    import os
    import sys
    data = [["äwien", "öbgld", "üktn", "noe", "ooe", "sbg", "stmk", "tirol", "vbg"]]
    path = os.path.abspath(os.path.dirname(sys.argv[0]))
    fn = os.path.join(path, "test.csv")
    with open(fn, 'w', newline='', encoding="utf-8") as f:
    writer = csv.writer(f, delimiter=";")
    writer.writerows(data)


    When I check the CSV file with a text editor everything is shown fine.

    But when I open the CSV with Excel it looks like that:

    [​IMG]

    How can I show the correct umlauts also in Excel?

    Continue reading...

Compartilhe esta Página