GCP AI Platform 无法读取存储在 Google Cloud Storage (Python) 中的 .SAV 文件
GCP AI Platform cannot read .SAV file stored in Google Cloud Storage (Python)
我有一个使用 Python3 笔记本设置的 AI Platform VM 实例。我还有一个 Google 云存储桶,其中包含大量 .CSV 和 .SAV 文件。我可以使用标准 python 软件包(例如 Pandas)从 CSV 文件中读取数据,但我的笔记本似乎无法在我的存储桶中找到我的 .SAV 文件。
有谁知道这里发生了什么and/or我该如何解决这个问题?
import numpy as np
import pandas as pd
import pyreadstat
df = pd.read_spss("gs://<STORAGE_BUCKET>/datafile.sav")
---------------------------------------------------------------------------
PyreadstatError Traceback (most recent call last)
<ipython-input-10-30836249273f> in <module>
----> 1 df = pd.read_spss("gs://<STORAGE_BUCKET>/datafile.sav")
/opt/conda/lib/python3.7/site-packages/pandas/io/spss.py in read_spss(path, usecols, convert_categoricals)
41
42 df, _ = pyreadstat.read_sav(
---> 43 path, usecols=usecols, apply_value_formats=convert_categoricals
44 )
45 return df
pyreadstat/pyreadstat.pyx in pyreadstat.pyreadstat.read_sav()
pyreadstat/_readstat_parser.pyx in pyreadstat._readstat_parser.run_conversion()
PyreadstatError: File gs://<STORAGE_BUCKET>/datafile.sav does not exist!
read_spss
function只能从本地文件路径读取:
path
: pathstr or Path - File path.
与 read_csv
function 比较:
filepath_or_bufferstr
: str, path object or file-like object -
Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, gs, and file. For file URLs, a host is expected.
我有一个使用 Python3 笔记本设置的 AI Platform VM 实例。我还有一个 Google 云存储桶,其中包含大量 .CSV 和 .SAV 文件。我可以使用标准 python 软件包(例如 Pandas)从 CSV 文件中读取数据,但我的笔记本似乎无法在我的存储桶中找到我的 .SAV 文件。
有谁知道这里发生了什么and/or我该如何解决这个问题?
import numpy as np
import pandas as pd
import pyreadstat
df = pd.read_spss("gs://<STORAGE_BUCKET>/datafile.sav")
---------------------------------------------------------------------------
PyreadstatError Traceback (most recent call last)
<ipython-input-10-30836249273f> in <module>
----> 1 df = pd.read_spss("gs://<STORAGE_BUCKET>/datafile.sav")
/opt/conda/lib/python3.7/site-packages/pandas/io/spss.py in read_spss(path, usecols, convert_categoricals)
41
42 df, _ = pyreadstat.read_sav(
---> 43 path, usecols=usecols, apply_value_formats=convert_categoricals
44 )
45 return df
pyreadstat/pyreadstat.pyx in pyreadstat.pyreadstat.read_sav()
pyreadstat/_readstat_parser.pyx in pyreadstat._readstat_parser.run_conversion()
PyreadstatError: File gs://<STORAGE_BUCKET>/datafile.sav does not exist!
read_spss
function只能从本地文件路径读取:
path
: pathstr or Path - File path.
与 read_csv
function 比较:
filepath_or_bufferstr
: str, path object or file-like object - Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, ftp, s3, gs, and file. For file URLs, a host is expected.