上传 .tar 文件时出现问题

问题描述 投票:0回答:1

我正在处理 .tar.Z 格式的文件。我手动更改了它的名称,因此它只有 .tar 扩展名,而我目前正在努力打开它并读取数据。我似乎找不到我做错了什么。

!pip install tslearn  #Library for Time Series

!pip install hmmlearn  #Library for Hidden Markov Models

import pandas as pd
import numpy as np
import time # For optimization purposes
import matplotlib.pyplot as plt
from matplotlib import cm
import pylab as pl
import io

from google.colab import drive

#Jupyter notebook option for display
pd.set_option('display.max_rows', None)
np.set_printoptions(threshold=np.inf)
%matplotlib inline

filename='diabetes-data'

uploaded = files.upload()

columnsNames = [
    'sequenceName',
    'TagIdentificator',
    'timestamp',
    'dateFORMAT',
    'x-coordinate-of-the-tag',
    'y-coordinate-of-the-tag',
    'z-coordinate-of-the-tag',
    'activity'
]

data = pd.read_csv(io.BytesIO(uploaded[filename]+'.tar'),encoding='latin1',header=None,names=columnsNames)

我做了一些研究,最终在发生字符读取错误时添加了“encoding='latin1'”,但我不知道如何解决这个问题。 非常感谢!

python file google-colaboratory file-format
1个回答
0
投票

tar.Z 表示它不仅仅是一个 tar 文件,而且还经过额外压缩。据我所知这是一个zip压缩。 您可能需要额外解压。

© www.soinside.com 2019 - 2024. All rights reserved.