Skip to content
ixhlbxi edited this page Apr 13, 2026 · 1 revision

Usage

CS Extract is a single-file CLI tool. All options are passed as command-line arguments to cs_extract.py.


Synopsis

python cs_extract.py <folder> [--output-dir DIR] [--csv] [--json]

Parameters

Parameter Type Required Default Description
folder Positional Yes -- Path to the folder containing CSLibrary XML files. Every .xml file in this directory will be parsed.
--output-dir Option No Same as folder Directory where output files are written. Must already exist.
--csv Flag No Off Write CSV output only.
--json Flag No Off Write JSON output only.

Format selection logic

  • If neither --csv nor --json is specified, both formats are written.
  • If one flag is specified, only that format is written.
  • If both flags are specified, both formats are written (same as the default).

Output Files

Flag Output filename Location
--csv coordinate_systems_extended.csv --output-dir (or input folder)
--json coordinate_systems_extended.json --output-dir (or input folder)

Examples

1. Extract everything (both CSV and JSON) to the input folder

python cs_extract.py /path/to/CSLibrary

Output:

Processing /path/to/CSLibrary/projected.xml...
Processing /path/to/CSLibrary/geographic.xml...
CSV output saved to: /path/to/CSLibrary/coordinate_systems_extended.csv
JSON output saved to: /path/to/CSLibrary/coordinate_systems_extended.json
Extraction complete.

2. Write only CSV to a different directory

python cs_extract.py /path/to/CSLibrary --csv --output-dir /path/to/output

3. Write only JSON, output alongside the XML files

python cs_extract.py /path/to/CSLibrary --json

4. Windows path example

python cs_extract.py "C:\Program Files\Autodesk\CSLibrary" --output-dir "D:\GIS\Output"

Error Handling

Condition Behavior
folder does not exist Prints Error: folder not found: <path> and exits with code 1.
--output-dir does not exist Prints Error: output directory not found: <path> and exits with code 1.
Malformed XML file Prints Error processing <path>: <details> and continues to the next file.
No XML files found Completes with zero records; output files are created but empty (CSV has only a header row, JSON contains []).

FAQ

Q: Does it recurse into subdirectories? A: No. Only .xml files directly inside the specified folder are processed. Subdirectories are ignored.

Q: What XML namespace does it expect? A: http://www.osgeo.org/mapguide/coordinatesystem. Files using a different namespace will yield zero records (no error).

Q: Can I pipe the output to stdout instead of a file? A: Not currently. The tool always writes to disk. You can read the resulting file immediately after the run completes.

Q: What Python version is required? A: Python 3.6 or later. No third-party packages are needed.