From f9e418c46041da099b827ed08bee0d66bb57927c Mon Sep 17 00:00:00 2001 From: "Gerber, Mike" Date: Wed, 6 Apr 2022 19:08:38 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Optionally=20output=20to=20an=20Exc?= =?UTF-8?q?el=20.xlsx=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qurator/modstool/modstool.py | 6 +++++- requirements.txt | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/qurator/modstool/modstool.py b/qurator/modstool/modstool.py index acf3bb5..e469146 100755 --- a/qurator/modstool/modstool.py +++ b/qurator/modstool/modstool.py @@ -451,7 +451,8 @@ def flatten(d: MutableMapping, parent='', separator='_'): @click.option('--output', '-o', 'output_file', type=click.Path(), help='Output pickle file', default='mods_info_df.pkl', show_default=True) @click.option('--output-csv', type=click.Path(), help='Output CSV file') -def process(mets_files: List[str], output_file: str, output_csv: str): +@click.option('--output-xlsx', type=click.Path(), help='Output Excel .xlsx file') +def process(mets_files: List[str], output_file: str, output_csv: str, output_xlsx: str): """ A tool to convert the MODS metadata in INPUT to a pandas DataFrame. @@ -521,6 +522,9 @@ def process(mets_files: List[str], output_file: str, output_csv: str): if output_csv: logging.info('Writing CSV to {}'.format(output_csv)) mods_info_df.to_csv(output_csv) + if output_xlsx: + logging.info('Writing Excel .xlsx to {}'.format(output_xlsx)) + mods_info_df.to_excel(output_xlsx) def main(): diff --git a/requirements.txt b/requirements.txt index 7bf25d4..5174936 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ click pandas tqdm lxml +openpyxl