Command line Interface

You can call your script in command line to dynamically modify importation params.

To prevent from importing csv file headers, type the following:

$ ./your_script.py -o1

To import only few lines (First ten’s), type the following:

$ ./your_script.py -l10

For further details:

$ ./your_script --help

Note

Command line options have a higher priority than the class definition arguments. For example, the configuration of your Openerp instance will be overwritten by the command line options you specified. Same for Session session arguments.

Shell options

Usage: SCRIPT NAME [options]

Options:
-h, --help show this help message and exit
-f FILENAME, --filename=FILENAME
 The CSV file to import.
-s DELIMITER, --separator=DELIMITER
 The delimiter of the CSV file.
-g QUOTECHAR, --quotechar=QUOTECHAR
 The quotechar of the CSV file.
-e ENCODING, --encoding=ENCODING
 The encoding of the CSV file.
-o OFFSET, --offset=OFFSET
 Offset (Usually used for header omission, default=1)
-d, --debug debug mode
-v, --verbose verbose mode
-q, --quiet don’t print anything to stdout
-l LIMIT, --limit=LIMIT
 Limit
-u USERNAME, --username=USERNAME
 Username
-p PASSWORD, --password=PASSWORD
 Password
-r HOST, --host=HOST
 Host to contact
-t PORT, --port=PORT
 Port used
-b DBNAME, --database=DBNAME
 Database name

Script automation

To help you to configure your first script, a script automation has been added. In order to properly configure each binding for each csv files, you can call the module Tool with python -m option.

$ python -m csv2oerp.tools /path/to/your/csv/file.csv > my_script.py

This will result of a preconfigured script for the file specified. If you have more than one file, you can juste add a list of paths separated by coma.

$ python -m csv2oerp.tools /path/to/your/csv/file_#1.csv,/path/to/your/csv/file_#2.csv > my_script.py

Note

Internaly, it is the csv.Sniffer class which is used to detect dialect.

See also

generate_code

Table Of Contents

Previous topic

Access Programming Interface

Next topic

Callbacks module

This Page