MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / write_csv

Function write_csv

src/formattedcode/output_csv.py:80–104  ·  view source on GitHub ↗
(results, output_file)

Source from the content-addressed store, hash-verified

78
79
80def write_csv(results, output_file):
81 # FIXME: this is reading all in memory
82 results = list(results)
83
84 headers = dict([
85 ('info', []),
86 ('license', []),
87 ('copyright', []),
88 ('email', []),
89 ('url', []),
90 ('package', []),
91 ])
92
93 # note: FIXME: headers are collected as a side effect and this is not great
94 rows = list(flatten_scan(results, headers))
95
96 ordered_headers = []
97 for key_group in headers.values():
98 ordered_headers.extend(key_group)
99
100 w = csv.DictWriter(output_file, fieldnames=ordered_headers)
101 w.writeheader()
102
103 for r in rows:
104 w.writerow(r)
105
106
107def flatten_scan(scan, headers):

Callers 1

process_codebaseMethod · 0.70

Calls 2

flatten_scanFunction · 0.70
valuesMethod · 0.45

Tested by

no test coverage detected