3 # Import the Arvados sdk module
6 # Get information about the task from the environment
7 this_task = arvados.current_task()
9 this_task_input = arvados.current_job()['script_parameters']['input']
11 # Create the object access to the collection referred to in the input
12 collection = arvados.CollectionReader(this_task_input)
14 # Create an object to write a new collection as output
15 out = arvados.CollectionWriter()
17 # Create a new file in the output collection
18 with out.open('0-filter.txt') as out_file:
19 # Iterate over every input file in the input collection
20 for input_file in collection.all_files():
21 # Output every line in the file that starts with '0'
22 out_file.writelines(line for line in input_file if line.startswith('0'))
24 # Commit the output to Keep.
25 output_locator = out.finish()
27 # Use the resulting locator as the output for this task.
28 this_task.set_output(output_locator)