Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import codecs
- import os
- # Find path of current file
- mypath = os.path.dirname(os.path.realpath(__file__))
- # Find list of all TSV files in this folder
- files = [f for f in os.listdir(mypath) if os.path.isfile(f) and
- os.path.splitext(f)[1] == '.tsv']
- for filename in files:
- # Read UTF-encoded data
- with codecs.open(filename,'rb','utf_8') as f:
- filename = os.path.splitext(filename)[0] + '.csv'
- # Write SHIFT-JIS encoded data
- with codecs.open(filename,'wb','cp932') as g:
- for line in f:
- g.write(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement