Skip to content
Advertisement

how to read csv files with mbcs codec in Python on Linux?

I’m trying to read CSV files with Western Europe (windows) encoding

JavaScript

This code works well on Windows but not on Linux 18.04. (Error: unknown encoding: mbcs) Indeed, in the codecs python documentation, we have the information:

JavaScript

is there another way/name to decode my files in python on Linux? (I have thousand of files so I can’t save as on Excel)

Advertisement

Answer

If your systems uses a Western Europe encoding on Windows, the mbcs encoding (the ANSI codepage) is cp1252. So you should use:

JavaScript

on both system to have a compatible code base.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement