程序报错 2021-07-15 14:46 采纳率: 80%
浏览 775
已采纳

python读取和存储hdf5文件无法使用中文路径

代码:

df.to_hdf('F:\中文路径\hdf5_file.h5',key='file1',mode='w')

报错内容:
Traceback (most recent call last):
File "F:/代码/code.py", line 48, in
hdf5_data.to_hdf('F:\中文路径\hdf5_file.h5',key='file1',mode='w')
File "E:\python\lib\site-packages\pandas\core\generic.py", line 2606, in to_hdf
pytables.to_hdf(
File "E:\python\lib\site-packages\pandas\io\pytables.py", line 277, in to_hdf
with HDFStore(
File "E:\python\lib\site-packages\pandas\io\pytables.py", line 561, in init
self.open(mode=mode, **kwargs)
File "E:\python\lib\site-packages\pandas\io\pytables.py", line 710, in open
self._handle = tables.open_file(self._path, self._mode, **kwargs)
File "E:\python\lib\site-packages\tables\file.py", line 315, in open_file
return File(filename, mode, title, root_uep, filters, **kwargs)
File "E:\python\lib\site-packages\tables\file.py", line 778, in init
self._g_new(filename, mode, **params)
File "tables/hdf5extension.pyx", line 492, in tables.hdf5extension.File._g_new
tables.exceptions.HDF5ExtError: HDF5 error back trace

File "C:\ci\hdf5_1545244154871\work\src\H5F.c", line 444, in H5Fcreate
unable to create file
File "C:\ci\hdf5_1545244154871\work\src\H5Fint.c", line 1364, in H5F__create
unable to open file
File "C:\ci\hdf5_1545244154871\work\src\H5Fint.c", line 1557, in H5F_open
unable to open file: time = Thu Jul 15 14:38:30 2021
, name = 'F:\中文路径\hdf5_file.h5', tent_flags = 13
File "C:\ci\hdf5_1545244154871\work\src\H5FD.c", line 734, in H5FD_open
open failed
File "C:\ci\hdf5_1545244154871\work\src\H5FDsec2.c", line 346, in H5FD_sec2_open
unable to open file: name = 'F:\中文路径\hdf5_file.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 302

End of HDF5 error back trace

Unable to open/create file 'F:\中文路径\hdf5_file.h5'

  • 写回答

3条回答 默认 最新

  • 天元浪子 Python领域优质创作者 2021-07-15 17:35
    关注

    何必要在一棵树上吊死呢?试试h5py,这才是读写hdf文件的正确方式。

    >>> import h5py
    >>> with h5py.File(r'D:\数据文件\hdf5demo.h5', 'r') as fp:
        lons = fp['lons'][()]
    
        
    >>> lons.shape
    (361, 721)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已采纳回答 7月15日
  • 创建了问题 7月15日

悬赏问题

  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答