Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76566

Re: python scikits.audiolab Sndfile special chars in file name

References (2 earlier) <lsuvu9$gjh$1@ger.gmane.org> <CABy8q87bC0jH8F_HjzDy2c7P_J3RwLvh-Yt9WdyGOteYgT3HAg@mail.gmail.com> <53F32F8E.6010502@mrabarnett.plus.com> <CABy8q86ALwE=JbJMv5OnG5U0mjnQJXB1nm3fQuxnwvkWZeb0=w@mail.gmail.com> <53F34F55.5080304@mrabarnett.plus.com>
From Furqan wasi <furqan@avpreserve.com>
Date 2014-08-19 18:30 +0500
Subject Re: python scikits.audiolab Sndfile special chars in file name
Newsgroups comp.lang.python
Message-ID <mailman.13150.1408455043.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

*with code *

# -*- coding: UTF-8 -*-
import numpy, os

from scikits.audiolab import Sndfile
from os import walk, path, stat
file = u"C:/Users/Furqan/Desktop/查找問題Reference/1.wav"
track1 = file

track_one_file_obj = Sndfile(track1, 'r')

Getting this
Traceback (most recent call last):
  File "D:/python/Interstitial Project/test.py", line 9, in <module>
    track_one_file_obj = Sndfile(track1, 'r')
  File "_sndfile.pyx", line 471, in
scikits.audiolab.pysndfile._sndfile.Sndfile.__init__
(scikits\audiolab\pysndfile\_sndfile.c:4092)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
24-27: ordinal not in range(128)


*and  with code *

# -*- coding: UTF-8 -*-
import numpy, os

from scikits.audiolab import Sndfile
from os import walk, path, stat
file = u"C:/Users/Furqan/Desktop/查找問題Reference/1.wav"
track1 = file


track_one_file_obj = Sndfile(track1.decode('utf-16'), 'r')
print(track_one_file_obj)


Traceback (most recent call last):
  File "D:/python/Interstitial Project/test.py", line 9, in <module>
    track_one_file_obj = Sndfile(track1.encode('utf-8'), 'r')
  File "_sndfile.pyx", line 488, in
scikits.audiolab.pysndfile._sndfile.Sndfile.__init__
(scikits\audiolab\pysndfile\_sndfile.c:4251)
IOError: error while opening C:/Users/Furqan/Desktop/查找問題Reference/1.wav
->error while opening file C:/Users/Furqan/Desktop/查找問題Reference/1.wav
 -> System error : The system cannot find the path specified.

*so what you think , what i should do is it possible to tackle to problem ?*




On Tue, Aug 19, 2014 at 6:21 PM, MRAB <python@mrabarnett.plus.com> wrote:

>
> On 2014-08-19 13:14, Furqan wasi wrote:
>
>>
>> Getting this
>>
>> file = ur"C:\Users\Furqan\Desktop\查找問題Reference\1.wav"
>> SyntaxError: (unicode error) 'rawunicodeescape' codec can't decode bytes
>> in position 2-3: truncated \uXXXX
>>
>>  Ouch! That's Python 2 treating \U as the start of a Unicode escape, even
> though it's in a raw string. That doesn't happen in Python 3 (which is what
> I use nowadays).
>
> Fortunately, Windows will accept / instead of \ in paths, which also means
> that you don't have to make it a raw string:
>
> file = u"C:/Users/Furqan/Desktop/查找問題Reference/1.wav"
>
>
>
>> On Tue, Aug 19, 2014 at 4:05 PM, MRAB <python@mrabarnett.plus.com
>> <mailto:python@mrabarnett.plus.com>> wrote:
>>
>>     On 2014-08-19 09:05, Furqan wasi wrote:
>>
>>         *Hi Mark and all, *
>>
>>
>>                   Thanks for the replay i appreciate your help but the
>>         problem i
>>         have is not with the FileNotFoundError exception handling
>>         because the
>>         file exists but the problem is that the library libsndfile/Sndfile
>>         (python third party) which is child class/module of
>>         scikits.audiolab
>>         (python third party) is not reading file with special
>>         character in its
>>         path and name , i need some help to in how to make library
>>         libsndfile/Sndfile to read file with special character in it  i.e
>>         C:\Users\Furqan\Desktop\test\查找問題daw\查找問題d.wav, as i
>>         mentioned
>>         in my first email
>>
>>     I recommend that you use Unicode strings instead of bytestrings:
>>
>>     track1 = ur'C:\Users\Furqan\Desktop\test\查找問題daw\查找問題d.wav'
>>
>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 

*Best Regards*

Furqan Wasi
*AVPreserve *

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: python scikits.audiolab Sndfile special chars in file name Furqan wasi <furqan@avpreserve.com> - 2014-08-19 18:30 +0500

csiph-web