Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'parameters': 0.04; 'arguments': 0.09; 'executes': 0.09; 'subject:files': 0.09; 'subject:using': 0.09; 'subject:while': 0.09; 'python': 0.11; 'command,': 0.16; 'expect,': 0.16; 'hadoop,': 0.16; 'loop.': 0.16; 'shalini': 0.16; 'skip:/ 60': 0.16; 'subject:Problem': 0.16; 'traceback.': 0.16; 'subject:python': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'everyone,': 0.19; 'properly': 0.19; 'typing': 0.19; 'help.': 0.21; 'seems': 0.21; 'import': 0.22; 'shell': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'script.': 0.24; 'file.': 0.24; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; 'code': 0.31; "skip:' 10": 0.31; 'towards': 0.31; 'parameters.': 0.31; 'pipe': 0.31; 'prints': 0.31; 'yourself.': 0.31; 'file': 0.32; 'supposed': 0.32; 'run': 0.32; 'running': 0.33; 'call.': 0.33; 'skip:# 10': 0.33; 'comment': 0.34; 'subject:from': 0.34; 'test': 0.35; 'but': 0.35; 'add': 0.35; 'really': 0.36; 'doing': 0.36; 'thanks': 0.36; 'should': 0.36; 'error.': 0.37; 'wrong': 0.37; 'displays': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'anything': 0.39; 'does': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'manually': 0.60; 'tell': 0.60; 'full': 0.61; 'different': 0.65; 'charset:windows-1252': 0.65; 'here': 0.66; 'dont': 0.67; 'anything.': 0.68; 'reads': 0.68; 'received:74.208': 0.68; 'behavior': 0.77; 'shell,': 0.91 Date: Tue, 03 Feb 2015 18:02:52 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Problem while reading files from hdfs using python References: <19c7923f-2f26-4752-ac2b-1b6dfc093631@googlegroups.com> In-Reply-To: <19c7923f-2f26-4752-ac2b-1b6dfc093631@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:MyyiNs+tAQTJ/LhP/jrKZcAcbyQaOdF9VOjvjiU0Td0 ADrOVED0quTbRYIn9T7k0N9I0O5+7+T0V0y99aUFXUtT1mzLHT 5YPZH2YO7NRbhAZXV4UrDTsSPvAnIgWjIJNBXLBhWock+nqjuZ HHtPVW8li903lFXn+cJ8el7cIZyb7oU1xve8ItQ2jcCdyV9cHW bu+haunmJVk6D+f+dJdGE1gLbW7PPeaPkoNnsGQgdUhM4VJbDQ KValrkHlZh0dIIBgoPcu1rrEC9EYf4H8JtJWOGJT7egOiHquDY hGtRrfhQjlWAG8fdpg8M0rwN1foMYbyvlZ+ugfVFIP8psIObg= = X-UI-Out-Filterresults: notjunk:1; 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: 77 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1423004594 news.xs4all.nl 2900 [2001:888:2000:d::a6]:46926 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85183 On 01/25/2015 03:23 PM, Shalini Ravishankar wrote: > Hello Everyone, > > I am trying to read(open) and write files in hdfs inside a python script. But having error. Please copy/paste the full error traceback. > Can someone tell me what is wrong here. > > Code (full): sample.py > > #!/usr/bin/python > > > from subprocess import Popen, PIPE > > print "Before Loop" > > cat = Popen(["hadoop", "fs", "-cat", "./sample.txt"], > stdout=PIPE) I don't know anything about hadoop, and when you run it separately, you used different parameters. So you can do a lot towards testing it yourself. Start by running hadoop fs -cat ... from shell to see whether it displays anything. You should be able to use exactly the same arguments as you use in the Popen call. Then if that seems to work as you expect, comment out your 'put' code below, and add some prints to the loop. Does that look reasonable? At that point, if both look reasonable, then try the inverse. Write some known data to the 'put' command, and see if it makes it into the appropriate file. Once again, you should be able to also test the program parameters and behavior from the shell, typing manually into stdin. > put = Popen(["hadoop", "fs", "-put", "-", "./modifiedfile.txt"], > stdin=PIPE) > for line in cat.stdout: > line += "Blah" > print line > put.stdin.write(line) > > cat.stdout.close() > cat.wait() > put.stdin.close() > put.wait() > > When I execute : > > hadoop jar /usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.5.1.jar -file ./sample.py -mapper './sample.py' -input sample.txt -output fileRead > > It executes properly I couldn't find the file which supposed to create in hdfs modifiedfile > > And When I execute : > > hadoop fs -getmerge ./fileRead/ file.txt > > Inside the file.txt, I got : > > Before Loop > Before Loop > > Can someone please tell me what I am doing wrong here ?? I dont think it reads from the sample.txt > > I would really appreciate the help. > > > -- > Thanks & Regards, > Shalini Ravishankar. > -- DaveA