Jul-25-2019, 11:16 AM
Hi all,
I did a small check against one key only to try finding out the reason for the mismatch in data when parsing the dictionary to the csv:
If I check it against:
I did a small check against one key only to try finding out the reason for the mismatch in data when parsing the dictionary to the csv:
import csv fields = ['CHK'] a = {'LCDY_PS-OT_PSC_46.90_-6.5_0.0': {'DIR': 'C:/Users/Usr/Desktop/Test/Test 1', 'FILE': 'PS-OT;R300;PSC;WD47;ROT-6.5;SEA2.0-6.0;DIR000-180.ofw', 'ID': 'DY', 'VSL': 'PS-OT', 'RAD': '300', 'PROP': 'PSC', 'WD': '47', 'ROT': '-6.5', 'HS': '2.0', 'TZ': '6.0', 'WEA': [0.0], 'NTT': '1200.00', 'NBT': '844.10', 'MX_OBS': '.2023', 'MX_SBS': '.2031', 'MN_VTS': 4.06, 'MX_VTS': 5.51, 'AST': '51.52', 'LB_OBA': '0.645', 'LB_OBB': '0.606', 'LB_SBA': '0.547', 'LB_SBB': '0.547', 'XTDP': '289.90', 'FDR': '0.017', 'FST': '9.25', 'FPL': '24.4', 'FATP': '5.04856863478451E-0005', 'FATC': '1.27143382878945E-0004', 'NO_OBS': '.1988', 'NO_SBS': '.1988', 'NO_VTS': 4.7, 'VTL': 0.0, 'HTL': 0.0, 'CHK': None}} with open("C:\\Users\\MBo\\Desktop\\test_output.csv", "w") as f: w = csv.DictWriter(f, fields) w.writeheader() for k in a: w.writerow({field: a[k].get(field) or k for field in fields})This returns:
Output:CHK
LCDY_PS-OT_PSC_46.90_-6.5_0.0
Which I do not understand. Why is it returning this when it should return "None". If I check it against:
fields = ['VSL']It returns:
Output:VSL
PS-OT