3 Copyright (C) The Arvados Authors. All rights reserved.
5 SPDX-License-Identifier: CC-BY-SA-3.0
8 # Import the Arvados sdk module
11 # Get information about the task from the environment
12 this_task = arvados.current_task()
14 this_task_input = arvados.current_job()['script_parameters']['input']
16 # Create the object access to the collection referred to in the input
17 collection = arvados.CollectionReader(this_task_input)
19 # Create an object to write a new collection as output
20 out = arvados.CollectionWriter()
22 # Create a new file in the output collection
23 with out.open('0-filter.txt') as out_file:
24 # Iterate over every input file in the input collection
25 for input_file in collection.all_files():
26 # Output every line in the file that starts with '0'
27 out_file.writelines(line for line in input_file if line.startswith('0'))
29 # Commit the output to Keep.
30 output_locator = out.finish()
32 # Use the resulting locator as the output for this task.
33 this_task.set_output(output_locator)