[clang] [analyzer][NFC] Simplify Analysis/csv2json.py (PR #161665)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 2 06:28:44 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-static-analyzer-1
Author: Balazs Benics (steakhal)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/161665.diff
1 Files Affected:
- (modified) clang/test/Analysis/csv2json.py (+4-4)
``````````diff
diff --git a/clang/test/Analysis/csv2json.py b/clang/test/Analysis/csv2json.py
index 3c20d689243e7..d7fb3491f82fa 100644
--- a/clang/test/Analysis/csv2json.py
+++ b/clang/test/Analysis/csv2json.py
@@ -44,7 +44,7 @@ def csv_to_json_dict(csv_filepath):
"""
try:
with open(csv_filepath, "r", encoding="utf-8") as csvfile:
- reader = csv.reader(csvfile)
+ reader = csv.reader(csvfile, skipinitialspace=True)
# Read the header row (column names)
try:
@@ -58,19 +58,19 @@ def csv_to_json_dict(csv_filepath):
json.dumps({}, indent=2)
return
- other_column_names = [name.strip() for name in header[1:]]
+ header_length = len(header)
data_dict = {}
for row in reader:
- if len(row) != len(header):
+ if len(row) != header_length:
raise csv.Error("Inconsistent CSV file")
exit(1)
key = row[0]
value_map = {}
- for i, col_name in enumerate(other_column_names):
+ for i, col_name in enumerate(header[1:]):
# +1 to skip the first column
value_map[col_name] = row[i + 1].strip()
``````````
</details>
https://github.com/llvm/llvm-project/pull/161665
More information about the cfe-commits
mailing list