GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

csvToJsonConverter.run()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 3
rs 10
1
import csv
2
import json
3
4
class csvToJsonConverter:
5
6
	PROPERTY_INDEX = 1
7
	CONSTRAINT_INDEX = 2
8
	JSON_BLOB_INDEX = 3
9
10
11
	def write_dump_list_to_file(self, dump_list, jsonPath):
12
		with open(jsonPath, 'w') as f:
13
				complete_dump = json.dump(dump_list, f)
14
15
16
	def create_dump_list(self, csvPath):
17
		with open(csvPath, 'r') as csv_file:
18
			csv_reader = csv.reader(csv_file)
19
			dump_list = []
20
			for line in csv_reader:
21
				csv_json_blob = json.loads(line[self.JSON_BLOB_INDEX])
22
				dump_element = {
23
					'Property': line[self.PROPERTY_INDEX], 
24
					'Constraint': line[self.CONSTRAINT_INDEX],
25
					'Constraint_Parameters': csv_json_blob
26
					}
27
				dump_list.append(dump_element)
28
		return dump_list
29
30
31
	def run(self, csvPath, jsonPath):
32
		dump_list = self.create_dump_list(csvPath)
33
		self.write_dump_list_to_file(dump_list, jsonPath)
34
35
			
36
def main():
37
	converter = csvToJsonConverter()
38
	converter.run("constraints.csv", "dump.json")
39
40
if __name__ == "__main__": main()