目前我有一个csv文件的.gz文件。我想把它解压缩
困难在于解压.gz文件后,需要进行bitewise操作才能将其转换为正确的格式
我有python中的代码可以工作,但我正在努力将其转换为R
def uncompress_file(file_location_gz, file_location_save):
with open(file_location_gz, "rb") as f:
data = f.read()
data2 = gzip.GzipFile(fileobj=BytesIO(data),
mode='rb').read()
data2 = bytearray(data2)
for i in range(len(data2)):
data2[i] ^= 0x95
with open(file_location_save, 'wb') as f_out:
f_out.write(data2)
任何帮助或建议都会非常有用
下面是R中函数的外观
我们使用
gzfile()
进行解压缩,然后将数据作为原始字节读取。我们使用xor转换这些字节,然后将字节写回相关问题 更多 >
编程相关推荐