From 0a9a66c2cc29c43deed82e2630c81d930d132d2c Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Wed, 6 Apr 2022 16:46:48 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Optionally=20output=20to=20a=20CSV?= =?UTF-8?q?=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves gh-9. --- qurator/modstool/modstool.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qurator/modstool/modstool.py b/qurator/modstool/modstool.py index cb0c424..acf3bb5 100755 --- a/qurator/modstool/modstool.py +++ b/qurator/modstool/modstool.py @@ -450,7 +450,8 @@ def flatten(d: MutableMapping, parent='', separator='_'): @click.argument('mets_files', type=click.Path(exists=True), required=True, nargs=-1) @click.option('--output', '-o', 'output_file', type=click.Path(), help='Output pickle file', default='mods_info_df.pkl', show_default=True) -def process(mets_files: List[str], output_file: str): +@click.option('--output-csv', type=click.Path(), help='Output CSV file') +def process(mets_files: List[str], output_file: str, output_csv: str): """ A tool to convert the MODS metadata in INPUT to a pandas DataFrame. @@ -517,6 +518,9 @@ def process(mets_files: List[str], output_file: str): # Pickle the DataFrame logging.info('Writing DataFrame to {}'.format(output_file)) mods_info_df.to_pickle(output_file) + if output_csv: + logging.info('Writing CSV to {}'.format(output_csv)) + mods_info_df.to_csv(output_csv) def main():