fathomnet / fathomnet-py

FathomNet Python client
https://fathomnet-py.readthedocs.io
MIT License
24 stars 3 forks source link

Allow for whitespace in comma separated lists #22

Closed Kmoran1512 closed 11 months ago

Kmoran1512 commented 11 months ago

The fathomnet generate api only allows for strict comma separated lists without spaces. It is standard in in CSVs to not have trailing spaces after commas. When writing, trailing commas are included for better legibility. I would like to suggest adding a strip to parsing comma separated lists as it doesn't lose any functionality and could support more legible lists. fathomnet-py/fathomnet/scripts/fathomnet_generate.py:

def comma_list(s: str) -> List[str]:
  return [x.strip() for x in s.split(',')]

Is there a reason not to include this? Are there any cases in which leading or trailing spaces are important?

kevinsbarnard commented 11 months ago

Hi @Kmoran1512, concept names in FathomNet may have leading/trailing whitespace; the comma_list function was implemented this way to avoid ambiguity of the concept specification in that case.

As an alternative to providing a list of concepts on the command line, you can use the --concepts-file option in lieu of --concepts, and point it to to a file with one concept per line, like

Bathochordaeus charon
Bathochordaeus mcnutti
Bathochordaeus stygius

e.g.

fathomnet-generate --output /path/to/output --concepts-file concepts.txt -v --taxa fathomnet
Kmoran1512 commented 11 months ago

Okay, if there is a chance for leading/trailing white space the current paradigm makes sense. Thanks for the response (and for the note about the concept file)!