CSV Importer
The CSV importer turns any CSV file with a header into a cc.json map. It does not matter which tool wrote the CSV: one column names the file, every other column with numbers becomes a metric. Use it for custom metrics that no parser or importer delivers, such as bug counts from your issue tracker or results of an in-house tool.
Quick start
Section titled “Quick start”Write a file newmetrics.csv:
path,bugs,review_findingsFile.js,4,500service/Service1.ts,40,20Import it:
ccsh csvimport newmetrics.csv -o newmetrics.cc.jsonnewmetrics.cc.json.gz holds the folder service with Service1.ts, the file File.js next to it, and the metrics
bugs and review_findings on both files. Open it in the Web Studio or merge it
with another map.
Options
Section titled “Options”| Option | Description |
|---|---|
FILE... | one or more CSV files, each with a header |
--path-column-name=<pathColumnName> | name of the column that holds the file path (default path) |
--path-separator=<pathSeparator> | separator between folders in the path (default /) |
-d, --delimiter=<csvDelimiter> | column delimiter (default ,) |
-o, --output-file=<outputFile> | output file; prints to stdout when omitted |
-nc, --not-compressed | write plain JSON instead of a gzip file |
-h, --help | show the help and exit |
Usage: ccsh csvimport [-h] [-nc] [-d=<csvDelimiter>] [-o=<outputFile>] [--path-column-name=<pathColumnName>] [--path-separator=<pathSeparator>] FILE...How the CSV is read
Section titled “How the CSV is read”- The first line is the header.
- The column named like
--path-column-name(case does not matter) holds the file path. Without such a column, the first column with a name is used. - The path builds the folder structure:
service/Service1.tsbecomes the fileService1.tsin the folderservice. Every row is a file. - Every other column becomes a metric named after its header. A cell counts only when it holds a non-negative number,
such as
40,3.5or3,5. Text and empty cells are left out. - Columns without a name, and columns whose name repeats an earlier one, are ignored with a warning.
With several CSV files, all rows go into one map. Rows with the same path end up on the same file, so you can combine metrics from different sources in one run:
ccsh csvimport size.csv bugs.csv -o combined.cc.jsonOutput
Section titled “Output”The metrics land in the metrics lens of the cc.json file, keyed by the node id of each file (excerpt):
"attributes": { "12613ba8c758725d": { "bugs": 4.0, "review_findings": 500.0 }, "0a12c853600c5fdc": { "bugs": 40.0, "review_findings": 20.0 }}Related
Section titled “Related”- CSV Exporter: the way back, from cc.json to CSV
- SourceMonitor Importer: CSV exports of SourceMonitor with their metric names mapped
- Merge Filter: combine the imported metrics with other maps