Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; '-*-': 0.07; 'subject:file': 0.07; 'subject:skip:s 10': 0.07; 'utf-8': 0.07; 'advance': 0.07; 'coding:': 0.09; 'except:': 0.09; 'exception.': 0.09; 'try:': 0.09; 'python': 0.11; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'using,': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'passing': 0.19; 'import': 0.22; 'header:User-Agent:1': 0.23; 'fine': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'characters': 0.30; 'code': 0.31; 'didnt': 0.31; "skip:' 40": 0.31; 'skip:r 60': 0.31; "they'll": 0.31; 'file': 0.32; 'could': 0.34; 'skip:s 30': 0.35; 'received:84': 0.35; 'but': 0.35; 'version': 0.36; 'thanks': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'unable': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'read': 0.60; 'catch': 0.60; "you're": 0.61; 'information': 0.63; 'skip:r 40': 0.68; 'special': 0.74; 'stat': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=LOXoQfm9 c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=u9EReRu7m0cA:10 a=tws551RkLzcA:10 a=uhsKNJJYFc0A:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=6wUrX8fhBvdi7CQWd6IA:9 a=QEXdDO2ut3YA:10 a=u2yh8jPBKaUA:10 X-AUTH: mrabarnett:2500 Date: Mon, 18 Aug 2014 18:13:44 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: python scikits.audiolab Sndfile special chars in file name References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 59 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408382031 news.xs4all.nl 2915 [2001:888:2000:d::a6]:39000 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76491 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.