Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e6f7019 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use py3 features in merge_csv.py."

parents 8e0e0e85 9430c17a
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
/*
 * 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
		},
	},
}
+6 −7
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import csv
import sys

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:]
]

@@ -31,10 +31,9 @@ for reader in csv_readers:
    headers = headers.union(reader.fieldnames)

# 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()
for reader in csv_readers:
    for row in reader:
        out.writerow(row)