Reads the data from the input file and pushes it to the output queue. :param input_file: Path to the input file. :param num_lines_read: Value to store the number of lines in the input file. :param max_lines_to_read: Maximum number of lines to read from the input file (for testing).
(input_file: Path, num_lines_read: Value, max_lines_to_read: int, work_queue: Queue)
| 13 | return cnt |
| 14 | |
| 15 | def read_data(input_file: Path, num_lines_read: Value, max_lines_to_read: int, work_queue: Queue): |
| 16 | """ |
| 17 | Reads the data from the input file and pushes it to the output queue. |
| 18 | :param input_file: Path to the input file. |
| 19 | :param num_lines_read: Value to store the number of lines in the input file. |
| 20 | :param max_lines_to_read: Maximum number of lines to read from the input file (for testing). |
| 21 | :param work_queue: Queue to push the data to. |
| 22 | """ |
| 23 | with gzip.GzipFile(input_file, "r") as f: |
| 24 | num_lines = 0 |
| 25 | for ln in f: |
| 26 | if ln == b"[\n" or ln == b"]\n": |
| 27 | continue |
| 28 | if ln.endswith(b",\n"): # all but the last element |
| 29 | obj = ln[:-2] |
| 30 | else: |
| 31 | obj = ln |
| 32 | num_lines += 1 |
| 33 | work_queue.put(obj) |
| 34 | if 0 < max_lines_to_read <= num_lines: |
| 35 | break |
| 36 | num_lines_read.value = num_lines |
| 37 | return |
nothing calls this directly
no outgoing calls
no test coverage detected