From 0ca1b55e75e88a199fd642153f1dcdd50081e936 Mon Sep 17 00:00:00 2001 From: donkirkby Date: Tue, 4 May 2021 16:27:14 -0700 Subject: [PATCH] Keep trying to find headers when some collated files are empty. --- micall/monitor/kive_watcher.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/micall/monitor/kive_watcher.py b/micall/monitor/kive_watcher.py index 2f59115d7..9493e4a61 100644 --- a/micall/monitor/kive_watcher.py +++ b/micall/monitor/kive_watcher.py @@ -619,7 +619,10 @@ def copy_outputs(self, if output_name.endswith('_fasta'): self.extract_fasta(source, target, sample_name) else: - self.extract_csv(source, target, sample_name, source_count) + self.extract_csv(source, + target, + sample_name, + source_count) source_count += 1 except FileNotFoundError: # Skip the file. @@ -632,8 +635,8 @@ def extract_csv(source, target, sample_name, source_count): reader = DictReader(source) fieldnames = reader.fieldnames if fieldnames is None: - # Empty file, nothing to copy. - return + # Empty file, nothing to copy. Raise error to keep source_count at 0. + raise FileNotFoundError(f'CSV file {source.name} is empty.') fieldnames = list(fieldnames) has_sample = 'sample' in fieldnames if not has_sample: