Advertisement
Guest User

WW S-JIS Encode v1

a guest
Apr 28th, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import codecs
  2. import os
  3.  
  4. # Find path of current file
  5. mypath = os.path.dirname(os.path.realpath(__file__))
  6. # Find list of all TSV files in this folder
  7. files = [f for f in os.listdir(mypath) if os.path.isfile(f) and
  8.          os.path.splitext(f)[1] == '.tsv']
  9. for filename in files:
  10. # Read UTF-encoded data
  11.     with codecs.open(filename,'rb','utf_8') as f:
  12.         filename = os.path.splitext(filename)[0] + '.csv'
  13. # Write SHIFT-JIS encoded data
  14.         with codecs.open(filename,'wb','cp932') as g:
  15.             for line in f:
  16.                 g.write(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement