Maintain header order in merge_csv am: 84c1cdf31f
am: 95d8ad47f0
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1731412 Change-Id: Ib52bb2a863cc4ee5718a3a3abc6c97f524510fd3
This commit is contained in:
@@ -219,7 +219,6 @@ func buildRuleToGenerateIndex(ctx android.ModuleContext, desc string, classesJar
|
|||||||
BuiltTool("merge_csv").
|
BuiltTool("merge_csv").
|
||||||
Flag("--zip_input").
|
Flag("--zip_input").
|
||||||
Flag("--key_field signature").
|
Flag("--key_field signature").
|
||||||
FlagWithArg("--header=", "signature,file,startline,startcol,endline,endcol,properties").
|
|
||||||
FlagWithOutput("--output=", indexCSV).
|
FlagWithOutput("--output=", indexCSV).
|
||||||
Inputs(classesJars)
|
Inputs(classesJars)
|
||||||
rule.Build(desc, desc)
|
rule.Build(desc, desc)
|
||||||
|
@@ -55,14 +55,15 @@ else:
|
|||||||
if entry.endswith('.uau'):
|
if entry.endswith('.uau'):
|
||||||
csv_readers.append(dict_reader(io.TextIOWrapper(zip.open(entry, 'r'))))
|
csv_readers.append(dict_reader(io.TextIOWrapper(zip.open(entry, 'r'))))
|
||||||
|
|
||||||
headers = set()
|
|
||||||
if args.header:
|
if args.header:
|
||||||
fieldnames = args.header.split(',')
|
fieldnames = args.header.split(',')
|
||||||
else:
|
else:
|
||||||
|
headers = {}
|
||||||
# Build union of all columns from source files:
|
# Build union of all columns from source files:
|
||||||
for reader in csv_readers:
|
for reader in csv_readers:
|
||||||
headers = headers.union(reader.fieldnames)
|
for fieldname in reader.fieldnames:
|
||||||
fieldnames = sorted(headers)
|
headers[fieldname] = ""
|
||||||
|
fieldnames = list(headers.keys())
|
||||||
|
|
||||||
# By default chain the csv readers together so that the resulting output is
|
# By default chain the csv readers together so that the resulting output is
|
||||||
# the concatenation of the rows from each of them:
|
# the concatenation of the rows from each of them:
|
||||||
|
Reference in New Issue
Block a user