Merge "Use py3 features in merge_csv.py." am: 3e6f701980 am: aad8e7b161
Change-Id: I7c1806c36a731ce823e45b2fd49cc7793ae50e3a
This commit is contained in:
30
tools/hiddenapi/Android.bp
Normal file
30
tools/hiddenapi/Android.bp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
python_binary_host {
|
||||||
|
name: "merge_csv",
|
||||||
|
main: "merge_csv.py",
|
||||||
|
srcs: ["merge_csv.py"],
|
||||||
|
version: {
|
||||||
|
py2: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
py3: {
|
||||||
|
enabled: true,
|
||||||
|
embedded_launcher: true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ import csv
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
csv_readers = [
|
csv_readers = [
|
||||||
csv.DictReader(open(csv_file, 'rb'), delimiter=',', quotechar='|')
|
csv.DictReader(open(csv_file, 'r'), delimiter=',', quotechar='|')
|
||||||
for csv_file in sys.argv[1:]
|
for csv_file in sys.argv[1:]
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -31,10 +31,9 @@ for reader in csv_readers:
|
|||||||
headers = headers.union(reader.fieldnames)
|
headers = headers.union(reader.fieldnames)
|
||||||
|
|
||||||
# Concatenate all files to output:
|
# Concatenate all files to output:
|
||||||
out = csv.DictWriter(sys.stdout, delimiter=',', quotechar='|', fieldnames = sorted(headers))
|
out = csv.DictWriter(sys.stdout, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL,
|
||||||
|
dialect='unix', fieldnames=sorted(headers))
|
||||||
out.writeheader()
|
out.writeheader()
|
||||||
for reader in csv_readers:
|
for reader in csv_readers:
|
||||||
for row in reader:
|
for row in reader:
|
||||||
out.writerow(row)
|
out.writerow(row)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user