对象名称中不允许使用

对象名称中不允许使用

本文介绍了对象名称中不允许使用``/''字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在HDF5文件中使用名称中带有"/"的结构.当我加载上述文件时,会收到以下警告:

I am working with a structure within the HDF5 file that has names with '/' in them. When I load said file, I get this warning:

 ⓔ  develop  In [1]  import pandas as pd

 ⓔ  develop  In [2]  store = pd.HDFStore('data/XXX-20150423-071618.h5')

 ⓔ  develop  In [3]  store
/home/XXX/virt/env/develop/lib/python2.7/site-packages/tables/group.
py:1156: UserWarning: problems loading leaf ``/log``::

  the ``/`` character is not allowed in object names: 'XXX/align/aft_port_end/extend_pressure'

The leaf will become an ``UnImplemented`` node.
  % (self._g_join(childname), exc))

我们可以进行更改,但这将是主要的PITA,并且涉及破解现有的关键文件.因此,在可能的情况下,我们不希望这样做.

We could change those but it would be a major PITA and would involve hacking existing critical files. So, while possible we would like not to do that.

我们可以通过任何方式在名称中使用"/"吗?

Is there any way we can have '/' in names or is it just not supported?

>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.5.final.0
python-bits: 64
OS: Linux
OS-release: 3.10.0-229.1.2.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8

pandas: 0.16.0
nose: 1.3.6
Cython: 0.22
numpy: 1.9.2
scipy: 0.15.1
statsmodels: None
IPython: 3.0.0
sphinx: 1.2.3
patsy: None
dateutil: 2.4.2
pytz: 2015.2
bottleneck: None
tables: 3.1.1
numexpr: 2.2.2
matplotlib: 1.4.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 0.9.7
pymysql: None
psycopg2: None

推荐答案

从技术上说,该文件是非法的HDF5- 5.2中的官方规范. HDF5路径名和导航清楚地将Name定义为非斜杠字符的字符串.因此,PyTables在这里拒绝您的输入是正确的(并且通过回退到UnImplemented节点而显得很客气).

Technically the file is illegal HDF5 - the official spec in 5.2. HDF5 Path Names and Navigation clearly defines Names to be strings of non-slash characters. So, PyTables isn't wrong to reject your input here (and it's being rather gracious by simply falling back to an UnImplemented node).

也就是说,如果您不只是担心入侵PyTables,则可以从 tables/path.py .据我所知,唯一的副作用是对象无法使用自然命名来使用,但这没什么大不了的.

That said, if you're not afraid of just hacking PyTables, you could disable the offending check from tables/path.py. As far as I can tell, the only side-effect of this will be that the objects will not be usable using natural naming, but that's not likely to be a big deal.

(注意:我以前没有使用过PyTables,所以这完全是基于我对代码的阅读.)

(Caveat: I have not used PyTables before, so this is based solely on my reading of the code.)

这篇关于对象名称中不允许使用``/''字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 00:28