1#!/usr/bin/env python3 2# SPDX-License-Identifier: GPL-2.0+ 3 4from os import path 5import os, csv 6 7from csv_collection import CSVCollection 8from ni_names import value_to_name 9 10CSV_DIR = 'csv' 11 12def to_csv(): 13 try: 14 os.makedirs(CSV_DIR) 15 except: 16 pass 17 18 csv_fname = path.join(CSV_DIR, 'blank_route_table.csv') 19 20 fieldnames = [sig for sig_val, sig in sorted(value_to_name.items())] 21 fieldnames.insert(0, CSVCollection.source_column_name) 22 23 with open(csv_fname, 'w') as F_csv: 24 dR = csv.DictWriter(F_csv, fieldnames, delimiter=';', quotechar='"') 25 dR.writeheader() 26 27 for sig in fieldnames[1:]: 28 dR.writerow({CSVCollection.source_column_name: sig}) 29 30if __name__ == '__main__': 31 to_csv() 32