Skip to content

Instantly share code, notes, and snippets.

@etrepum
Created February 24, 2014 19:30
Show Gist options
  • Save etrepum/9195248 to your computer and use it in GitHub Desktop.
Save etrepum/9195248 to your computer and use it in GitHub Desktop.
UTF-16 w/ BOM tab delimited CSV in Excel
>>> open('chinese.csv', 'w').write(u'English\tChinese\r\nChinese\t汉语\r\n'.encode('utf-16'))
>>> open('chinese.csv', 'r').read()
'\xff\xfeE\x00n\x00g\x00l\x00i\x00s\x00h\x00\t\x00C\x00h\x00i\x00n\x00e\x00s\x00e\x00\r\x00\n\x00C\x00h\x00i\x00n\x00e\x00s\x00e\x00\t\x00Il\xed\x8b\r\x00\n\x00'
>>> os.system("open -a 'Microsoft Excel' chinese.csv")
@etrepum
Copy link
Author

etrepum commented Feb 24, 2014

screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment