Skip to content

How to handle one or more file inputs #322

@weiji14

Description

@weiji14

Description of the desired feature

There are a lot of GMT processing scripts that take in one or more table/grid inputs, and I was wondering how this should be handled. This came up as I was trying to wrap text at #321 and it also applies to grdtrack at #308 and other functions (see e.g. this search).

In gmt bash, it looks something like this:

gmt func data1.txt data2.txt -A -B -C

Implementation ideas

So the least amount of work would be to disallow multiple file inputs and force the user write a for-loop to process each file separately. This 'feature' would then need to be documented somewhere.

Another way I've thought about is to patch the kwargs_to_string function in decorators.py to include a 'sequence_space' convertor. This means a user can pass in a list of filenames (e.g. ["data1.txt", "data2.txt"]) which will be converted into a space-separated string (i.e. "data1.txt data2.txt") that can then be passed into the wrapper function when we do:

arg_str = " ".join([fnames, build_arg_string(kwargs)])
lib.call_module("somefunction", arg_str)

Thoughts?

Are you willing to help implement and maintain this feature? Yes!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions