Great!

Thanks.

2009/1/22 Francesc Alted <fal...@pytables.com>:
> A Thursday 22 January 2009, Vicent Mas escrigué:
>> Hi,
>>
>> In a Windows XP I've renamed a PyTables file to a name containing the
>> unicode character \u0140. As this character is not mapped to any key
>> in my keyboard I used the charmap application to write the name and
>> then copy and paste. My problem is that I don't know how to open this
>> file. What I've tried is:
>>
>> 1) pass the python unicode string to the openFile method. It fails:
>>
>> In [63]: f = tables.openFile(u'para\u0140lels.h5')
>> ---------------------------------------------------------------------
>>------ UnicodeEncodeError                        Traceback (most
>> recent call last)
>>
>> C:\Documents and Settings\vmas\Escritorio\tonto\paraig³a\<ipython
>> console> in <m odule>()
>>
>> C:\Python25\lib\site-packages\tables\file.pyc in openFile(filename,
>> mode, title, rootUEP, filters, nodeCacheSize, **kwargs)
>>     239
>>     240     # Finally, create the File instance, and return it
>> --> 241     return File(path, mode, title, rootUEP, filters,
>> **params) 242
>>     243
>>
>> C:\Python25\lib\site-packages\tables\hdf5Extension.pyd in
>> tables.hdf5Extension.F ile.__cinit__()
>>
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\u0140' in
>> position 4
>>
>> : ordinal not in range(128)
>>
>> 2) Try to find out the encoded representation of the unicode string
>> and use it
>>
>> In [65]: sys.getfilesystemencoding()
>> Out[65]: 'mbcs'
>>
>> In [66]: fname = u'para\u0140lels.h5'.encode('mbcs')
>>
>> In [67]: fname
>> Out[67]: 'para?lels.h5'
>>
>> In [68]: f = tables.openFile(fname)
>> ---------------------------------------------------------------------
>>------ IOError                                   Traceback (most
>> recent call last)
>>
>> C:\Documents and Settings\vmas\Escritorio\tonto\paraig³a\<ipython
>> console> in <m odule>()
>>
>> C:\Python25\lib\site-packages\tables\file.pyc in openFile(filename,
>> mode, title, rootUEP, filters, nodeCacheSize, **kwargs)
>>     239
>>     240     # Finally, create the File instance, and return it
>> --> 241     return File(path, mode, title, rootUEP, filters,
>> **params) 242
>>     243
>>
>> C:\Python25\lib\site-packages\tables\hdf5Extension.pyd in
>> tables.hdf5Extension.F ile.__cinit__()
>>
>> C:\Python25\lib\site-packages\tables\utils.pyc in
>> checkFileAccess(filename, mode )
>>     145         # The file should be readable.
>>     146         if not os.access(filename, os.F_OK):
>> --> 147             raise IOError("``%s`` does not exist" %
>> (filename,)) 148         if not os.path.isfile(filename):
>>     149             raise IOError("``%s`` is not a regular file" %
>> (filename,))
>>
>> IOError: ``para?lels.h5`` does not exist
>>
>> In [69]:
>>
>> So what have I to do in order to open the file?
>
> Well, it seems that PyTables doesn't support unicodes filenames.
> However, fixing that was surprisingly easy.  See:
>
> http://www.pytables.org/trac/ticket/202
>
> HTH,
>
> --
> Francesc Alted
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> Pytables-users mailing list
> Pytables-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pytables-users
>



-- 
Share what you know, learn what you don't.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to