Skip to content

Commit

Permalink
cli: default to excel outfmt for multi-csv
Browse files Browse the repository at this point in the history
  • Loading branch information
zargot committed Oct 22, 2024
1 parent c070001 commit 38b0ebd
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/odm_sharing/tools/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ def get_debug_writer(debug: bool) -> Union[TextIO, contextlib.nullcontext]:
return contextlib.nullcontext()


def infer_outfmt(path: str) -> OutFmt:
(_, ext) = os.path.splitext(path)
if ext == '.csv':
def infer_outfmt(inputs: List[str]) -> OutFmt:
first = inputs[0]
(_, ext) = os.path.splitext(first)
if ext == '.csv' and len(inputs) == 1:
return OutFmt.CSV
else:
return OutFmt.EXCEL
return OutFmt.EXCEL


def share(
Expand All @@ -167,9 +167,8 @@ def share(
schema_path = schema
schema_filename = Path(schema_path).name
schema_name = Path(schema_path).stem
first_input = inputs[0]
if outfmt == OutFmt.AUTO:
outfmt = infer_outfmt(first_input)
outfmt = infer_outfmt(inputs)
logging.info(f'inferred output format as {outfmt}')

logging.info(f'loading schema {qt(schema_filename)}')
Expand Down

0 comments on commit 38b0ebd

Please sign in to comment.