Hi I am creating a Pandas DF from this peice of code:
for odfslogp_obj in odfslogs_plist:
with zipfile.ZipFile(odfslogp_obj, mode='r') as z:
for name in z.namelist():
with z.open(name) as etest_zip:
tdict = {}
etestlines = [line.decode() for line in etest_zip] #change lines from log files from binary to text
regval_range_tup_list = list(zip([i for i,x in enumerate(etestlines) if 'Head' in x ], [i for i,x in enumerate(etestlines) if 'BINS' in x ])) #get binval sections
head_siteparam_tup_list = list(zip([x.split("=")[1].replace("(",'').replace(")",'').rstrip() for x in etestlines if 'Head' in x], [x.split(":")[2].rstrip() for x in etestlines if 'SITE:PARAM_SITE:' in x])) #extract head and site:param values from bin val sections
print(head_siteparam_tup_list)
linesineed = [etestlines[range[0]:range[1]-1] for range in regval_range_tup_list]
reglinecount = []
regvals = []
for head_site, loclist in zip(head_siteparam_tup_list, linesineed):
regvals_ext = [x for x in loclist if pattern.search(x)]
regvaltups_list = [tuple(x.split(":")[0:2]) for x in regvals_ext]
regvaldict = dict(regvaltups_list)
df = pd.DataFrame(data=regvaldict)
print(df)
The Sample of output of the dictionary being used looks like this when printed:
{'1000': '1669.15', '10012': '-0.674219', '10013': '-0.260156', '1003': '9.5792', '1007': '11.9812', '1011': '27.888', '1012': '14.8333', '1014': '19.1812', '1015': '19.0396', '1024': '1352.66', '1025': '3247.63', '1026': '33.7434', '1027': '38.7566', '1030': '19.7548', '1031': '30.2201'}
As you can see they are all strings, so why is it giving me this error? And how do i fix it?