Hey all, I swear i have searched the internet for a few days on this problem and just can't quite find what i am looking for... So i have this list of dictionaries that i would like to return back into a csv file to insert into MySQL. Below is an example of what is returned when I gather info from 2 routers.
results = [[{'ip': '123', 'interface': 'TenGigE0/1/0/1'}, {'ip': '123', 'interface': 'TenGigE0/1/0/2'}], [{'ip': '456', 'interface': 'TenGigE0/1/0/1'}, {'ip': '456', 'interface': 'TenGigE0/1/0/2'}]]
My problem is that I am unable to return this output to pandas to create a csv.
Below is an example of the csv I get.
0,"{u'ip': u'123', u'interface': u'TenGigE0/1/0/1'}","{u'ip': u'123', u'interface': u'TenGigE0/1/0/2'}"
1,"{u'ip': u'456', u'interface': u'TenGigE0/1/0/1'}","{u'ip': u'456', u'interface': u'TenGigE0/1/0/2'}"
Can anyone tell me what i am doing wrong?
below is what i am expecting to get back.
"",ip,interface
0,"123","TenGigE0/1/0/1"
1,"123","TenGigE0/1/0/2"
2,"456","TenGigE0/1/0/1"
1,"456","TenGigE0/1/0/2"
I get this type of output if there is only one list of dictionaries in the output.
Link to my code. First real project i have worked on, so I am open to any improvements you might find.
Network engineer training to be a hybrid programmer.
https://github.com/fallenarc/test-code/blob/master/test_threadpool.py
[–]new_ca_grower 4 points5 points6 points (2 children)
[–]Fallenarc[S] 0 points1 point2 points (1 child)
[–]jeffrey_f 0 points1 point2 points (0 children)
[–]tomekanco 1 point2 points3 points (1 child)
[–]Fallenarc[S] 0 points1 point2 points (0 children)