Reading files with hdfs3 fails
<p>I am trying to read a file on HDFS with Python using the hdfs3 module. </p>

<pre><code>import hdfs3
hdfs = hdfs3.HDFileSystem(host='xxx.xxx.com', port=12345)
hdfs.ls('/projects/samplecsv/part-r-00000')
</code></pre>

<p>This produces</p>

<pre><code>[{'block_size': 134345348,
  'group': 'supergroup',
  'kind': 'file',
  'last_access': 1473453452,
  'last_mod': 1473454723,
  'name': '/projects/samplecsv/part-r-00000/',
  'owner': 'dr',
  'permissions': 420,
  'replication': 3,
  'size': 98765631}]
</code></pre>

<p>So it seems to be able to access the HDFS and read the directory structure. However, reading the file fails.</p>

<pre><code>with hdfs.open('/projects/samplecsv/part-r-00000', 'rb') as f:
    print(f.read(100))
</code></pre>

<p>gives</p>

<pre><code>---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
.
.&lt;snipped&gt;
.

OSError: [Errno Read file /projects/samplecsv/part-r-00000 Failed:] 1
</code></pre>

<p>What could be the issue? I am using Python3.5.</p>

<p>if You want any operation on files then you have to pass full  File path  .</p>

<pre><code>import hdfs3
hdfs = hdfs3.HDFileSystem(host='xxx.xxx.com', port=12345)
hdfs.ls('/projects/samplecsv/part-r-00000')

#you have to add file to location
hdfs.put('local-file.txt', '/projects/samplecsv/part-r-00000')

with hdfs.open('projects/samplecsv/part-r-00000/local-file.txt', 'rb') as f:
    print(f.read(100))
</code></pre>

python hadoop hdfs