Skip to content

Commit 13c83c0

Browse files
authored
[analyzer][NFC] Simplify Analysis/csv2json.py (#161665)
1 parent 9e3bbbb commit 13c83c0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clang/test/Analysis/csv2json.py

Lines changed: 4 additions & 3 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,12 +58,13 @@ 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)
62+
other_column_names = header[1:]
6263

6364
data_dict = {}
6465

6566
for row in reader:
66-
if len(row) != len(header):
67+
if len(row) != header_length:
6768
raise csv.Error("Inconsistent CSV file")
6869
exit(1)
6970

0 commit comments

Comments
 (0)