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


Groups > comp.lang.python > #76491 > unrolled thread

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

Started byMRAB <python@mrabarnett.plus.com>
First post2014-08-18 18:13 +0100
Last post2014-08-18 18:13 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: python scikits.audiolab Sndfile special chars in file name MRAB <python@mrabarnett.plus.com> - 2014-08-18 18:13 +0100

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

FromMRAB <python@mrabarnett.plus.com>
Date2014-08-18 18:13 +0100
SubjectRe: python scikits.audiolab Sndfile special chars in file name
Message-ID<mailman.13104.1408382031.18130.python-list@python.org>
On 2014-08-18 16:34, Furqan wasi wrote:
> Hi ,
>
> Could you help me out on this , or guide me to some how can thanks
>
> I am trying to get a wav file information but Sndfile is unable to read
> file with special characters in path and file name(查找問題daw.wav) and
> i am unable to get information in any way , i tried passing file path to
> Sndfile  with diferent encoding to but didnt work , but if i pass this
> 'C:\Users\Furqan\Desktop\test\DAW\1.wav' it works fine , Thanks is advance
>
> My Code is
> # -*- coding: UTF-8 -*-
> from scikits.audiolab import Sndfile
> from os import walk, path, stat
>
> track1 =  r'C:\Users\Furqan\Desktop\test\查找問題daw\查找問題d.wav'
> #track2 = r'C:\Users\Furqan\Desktop\test\DAW\1.wav'
>
> try:
>      track_one_file_obj = Sndfile(track1, 'r')
> except:
>      print('Simple didnt work')
>      pass
>
> try:
>      track_one_file_obj = Sndfile(track1.decode('cp1252'), 'r')
> except:
>      print('cp1252 didnt work')
>      pass
>
> try:
>      track_one_file_obj = Sndfile(track1.encode('utf-8'), 'r')
>      print(track_one_file_obj)
> except:
>      print('encode didnt work')
>      pass
>
>
> try:
>      track_one_file_obj = Sndfile(track1.encode('utf8'), 'r')
>      print(track_one_file_obj)
> except:
>      print('encode didnt work')
>      pass
>
> try:
>      track_one_file_obj = Sndfile(track1.decode('utf-8'), 'r')
>      print(track_one_file_obj)
> except:
>      print('decode didnt work')
>      pass
>
You don't say which version of Python you're using, or what you mean by 
"didn't work".

Also, don't use 'bare' excepts; they'll catch _any_ exception. Be
specific in what you catch.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web