summaryrefslogtreecommitdiff
path: root/scripts/hiddenapi/merge_csv.py
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2021-06-08 15:41:32 +0100
committer Paul Duffin <paulduffin@google.com> 2021-06-09 14:02:03 +0100
commit84c1cdf31f8f888ee9c0beb201d35ad9d293c341 (patch)
tree78089b28ef5f7b02288fe0b645060dfe5f5f2f4b /scripts/hiddenapi/merge_csv.py
parenta4d9b86c8b5042470df3a8cc80824f538eba0642 (diff)
Maintain header order in merge_csv
Previously, if the --header property was not specified then merge_csv would use a header constructed by sorting all the fields in the input files. That required that any use of merge_csv which did not already have headers in the required order would have to explicitly specify the headers. That made it harder to use merge_csv as a generic tool as each invocation needed to be aware of what headers were exported in the output. This change causes merge_csv to simply use the headers in the order in which they are encountered in the input files. That removes the need to specify the --header option when generating the index files. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-index.csv out/soong/hiddenapi/hiddenapi-unsupported.csv - make sure that they are not changed by this change. Change-Id: I420b7d07aea85af6372cd7580a8be5e2cc82a513
Diffstat (limited to 'scripts/hiddenapi/merge_csv.py')
-rwxr-xr-xscripts/hiddenapi/merge_csv.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/hiddenapi/merge_csv.py b/scripts/hiddenapi/merge_csv.py
index b047aab71..a65326c51 100755
--- a/scripts/hiddenapi/merge_csv.py
+++ b/scripts/hiddenapi/merge_csv.py
@@ -55,14 +55,15 @@ else:
if entry.endswith('.uau'):
csv_readers.append(dict_reader(io.TextIOWrapper(zip.open(entry, 'r'))))
-headers = set()
if args.header:
fieldnames = args.header.split(',')
else:
+ headers = {}
# Build union of all columns from source files:
for reader in csv_readers:
- headers = headers.union(reader.fieldnames)
- fieldnames = sorted(headers)
+ for fieldname in reader.fieldnames:
+ headers[fieldname] = ""
+ fieldnames = list(headers.keys())
# By default chain the csv readers together so that the resulting output is
# the concatenation of the rows from each of them: