Skip to content

Commit 88e6a29

Browse files
committed
[analyzer][NFC] Simplify Analysis/csv2json.py
1 parent e48fe76 commit 88e6a29

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clang/test/Analysis/csv2json.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def csv_to_json_dict(csv_filepath):
4444
"""
4545
try:
4646
with open(csv_filepath, "r", encoding="utf-8") as csvfile:
47-
reader = csv.reader(csvfile)
47+
reader = csv.reader(csvfile, skipinitialspace=True)
4848

4949
# Read the header row (column names)
5050
try:
@@ -58,19 +58,19 @@ def csv_to_json_dict(csv_filepath):
5858
json.dumps({}, indent=2)
5959
return
6060

61-
other_column_names = [name.strip() for name in header[1:]]
61+
header_length = len(header)
6262

6363
data_dict = {}
6464

6565
for row in reader:
66-
if len(row) != len(header):
66+
if len(row) != header_length:
6767
raise csv.Error("Inconsistent CSV file")
6868
exit(1)
6969

7070
key = row[0]
7171
value_map = {}
7272

73-
for i, col_name in enumerate(other_column_names):
73+
for i, col_name in enumerate(header[1:]):
7474
# +1 to skip the first column
7575
value_map[col_name] = row[i + 1].strip()
7676

0 commit comments

Comments
 (0)