Skip to content

CSV Exporter

The CSV exporter writes the metrics of a cc.json map as a CSV table: one row per file, one column per metric. Use it to sort and filter metrics in a spreadsheet, to compare runs with your own scripts or to hand numbers to a tool that does not read cc.json.

Terminal window
ccsh csvexport project.cc.json.gz -o project.csv

Leave out -o to print the CSV to the console.

OptionDescription
FILE or FOLDER...one or more cc.json files, or folders that contain them
--depth-of-hierarchy=<maxHierarchy>number of dir columns that split up the path (default 10, at least 0)
-o, --output-file=<outputFile>output file; .csv is added when missing; prints to stdout when omitted
-h, --helpshow the help and exit
Usage: ccsh csvexport [-h] [--depth-of-hierarchy=<maxHierarchy>]
[-o=<outputFile>] FILE or FOLDER...
  • Every node that carries at least one metric gets one row.
  • path holds the path of the node below the root, with / between folders, name its name and type whether it is a File or a Folder.
  • One column per metric follows. A node without a value for a metric leaves that cell empty.
  • dir0, dir1, and so on hold the folders of the path one by one, so you can group rows by folder in a spreadsheet. --depth-of-hierarchy sets how many of these columns there are. A negative value is rejected.
path,name,type,rloc,mcc,coverage,dir0,dir1
README.md,README.md,File,3.0,,,,
src/a.ts,a.ts,File,10.0,2.0,80.0,src,
src/lib/b.ts,b.ts,File,20.0,5.0,,src,lib

The example above comes from --depth-of-hierarchy=2.

With several files, or a folder, each map is written one after another into the same CSV file, every map with its own header line. Pass -o for several inputs: printed to the console, only the first map appears.