Initiate snakebite
client
from snakebite.client import Client
client = Client("my.host.com", 8020, effective_user='datascientist',
use_datanode_hostname=True)
List the items in the directory and collect the files
files = []
for x in client.ls(['/user/datascientist']):
if x['file_type'] == 'f':
files.append(x['path'])
files
['/user/datascientist/da-foobar-2.txt', '/user/datascientist/da-foobar.txt']
Print the files (using join
)
''.join(client.text(files))
'Yet another file\nmy file is this\ntest file\nmy file is this\ntest file'
Or using a loop
for cat in client.text(files):
print(cat)
Yet another file my file is this test file my file is this test file