Hello :) I have a big bin file which has been gzipped (so it's a blabla.bin.gz).
I need to decompress and write it to a txt file with ascii format. Here's my code :
import gzip
with gzip.open("GoogleNews-vectors-negative300.bin.gz", "rb") as f:
file_content = f.read()
file_content.decode("ascii")
output = open("new_file.txt", "w", encoding="ascii")
output.write(file_content)
output.close()
But I got this error :
file_content.decode("ascii")
UnicodeDecodeError: 'ascii' codec can't decode byte 0x94 in position 19: ordinal not in range(128)
I'm not so new to Python but format/coding problems have always been my greatest weakness :(
Please, could you help me?
Thank you !!!
encoding='utf-8',or justfile_content.decode("utf-8")- better get used to utf-8 - its kindof a default nowadays.file_content.decode('cp1252')work?0x94is a closing curly double quote in cp1252, which is a common encoding on Windows systems.