Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'ok.': 0.07; 'raises': 0.07; 'encoding.': 0.09; 'texts.': 0.09; 'decoding': 0.16; 'folder.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'subject:Different': 0.16; 'subject:Opening': 0.16; 'wrote:': 0.17; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'received:192.168.1.3': 0.29; 'could': 0.32; 'to:addr:python-list': 0.33; 'wrong': 0.34; 'list': 0.35; 'compared': 0.35; 'formats': 0.35; 'but': 0.36; 'characters': 0.36; 'method': 0.36; 'subject:: ': 0.38; 'files': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'group,': 0.60; 'skip:u 10': 0.60; 'different': 0.63; 'frequency': 0.65; 'dear': 0.66; 'header:Reply-To:1': 0.68; 'believe': 0.69; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=coAZYiEi c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=YsUzL_8ObRgA:10 a=TDBgY0uxmmgA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=a2OjE2N3Sdrwmx1LkKoA:9 a=wPNLvfGTeEIA:10 a=acJJsc-yTrLaYIpF:21 a=LKRmTKzKVWxb3eFU:21 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Tue, 10 Jul 2012 20:26:22 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Opening multiple Files in Different Encoding References: <40633830-78ae-4cc6-8795-de5a352e0fb1@m2g2000pbv.googlegroups.com> In-Reply-To: <40633830-78ae-4cc6-8795-de5a352e0fb1@m2g2000pbv.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341948384 news.xs4all.nl 6990 [2001:888:2000:d::a6]:49986 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25154 On 10/07/2012 18:46, Subhabrata wrote: > Dear Group, > > I kept a good number of files in a folder. Now I want to read all of > them. They are in different formats and different encoding. Using > listdir/glob.glob I am able to find the list but how to open/read or > process them for different encodings? > > If any one can help me out.I am using Python3.2 on Windows. > You could try different encodings. If it raises a UnicodeDecodeError, then it's the wrong encoding, Otherwise just look at the decoding result and see whether it "looks" OK. I believe that one method is to look at the frequency distribution of characters compared with sample texts.