D
D
Damir Gabdrakhimov2018-12-17 13:45:36
Python
Damir Gabdrakhimov, 2018-12-17 13:45:36

Python. How to solve the problem with the encoding of the CSV file output in the terminal?

Good afternoon, I started learning Python, got to CSV files and outputting their data to the terminal.
I ran into an encoding problem.
Plz tell me what to insert where so that there is no kryakozyabr?
System: Windows 10, Python 3.7.1, Visual Studio Code, cmder terminal as bash
Code:

exampleFile = open('example.csv')
exampleReader = csv.reader(exampleFile)
exampleData = list(exampleReader)
print(exampleData)

Conclusion:
5c177e2b6eb4a357964294.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shatalov, 2018-12-17
@netpastor

https://docs.python.org/3/library/csv.html#reader-...

import csv
with open('some.csv', newline='', encoding='utf-8') as f:
    reader = csv.reader(f)
    for row in reader:
        print(row)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question