Created
September 21, 2012 11:40
-
-
Save ckunte/3761008 to your computer and use it in GitHub Desktop.
Cyrillic (csv or Excel) file to UTF-8 (csv) file converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
c2u.py | |
Created by ckunte on 2012-09-21. | |
Note: Keep the following file be placed in the same folder | |
as this script file. | |
Usage (run in Mac Terminal or Gnome Terminal): | |
$ python c2u.py | |
""" | |
import codecs, csv | |
def main(): | |
# There are two codecs (cp1251, iso8859_5). | |
# One of the above two should work. | |
# Comment the line below with # if you use a .xls file. | |
f = csv.reader('filename.xls', dialect='excel', **fmtparams) | |
# Comment the line above, and uncomment the line below | |
# if you use a .csv file. | |
# f = codecs.open('filename.csv', 'rb', 'iso8859_5') | |
u = f.read() | |
o = codecs.open('output.csv', 'w', 'utf-8') | |
o.write(u) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment