D
D
denislysenko2021-09-28 13:45:23
Python
denislysenko, 2021-09-28 13:45:23

How to write a console utility using the argparse module?

write a converter.py console utility that supports command line arguments.

python convert.py [--csv2parquet | --parquet2csv ] | [--get-schema] | [--help]

utility supports
- csv to parquet
conversion mode - parquet to csv conversion mode
- getting the parquet file schema
- displaying help on its use

which sections of the argparse module should be learned to do it as quickly as possible?
what arguments should be passed?
and in general, can anyone give feedback on this task, what needs to be done, etc., etc.?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-09-28
@denislysenko

Open documentation on the module at least.
The first example already gives an idea of ​​how the code will be organized.
You create a parser object, add parameter descriptions to it with add_argument() calls, then pit it against command line arguments with parse_args() which will return you an object containing the parsed parameters as attributes. You already use this object (its attributes) at your own discretion.
All that remains after that is to figure out the add_argument () method and its parameters, what they are responsible for, and what behavior they provide.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question