Jul-24-2023, 10:52 AM
I have used sqlitedict to save a number of dictionaries into a database.
eg
ford = {'make': 'Ford', 'wheels': '4', 'colour': 'black'}
mahindra = {'make': 'Mercedes', 'wheels': '4', 'colour': 'white'}
reliant = {'make': 'Robin', 'wheels': '3', 'colour': 'rusty yellow'}
I can retrieve all the dictionaries data with a for items loop.
What I want to do is make list of just the keys from the first dictionary so that I can use it as column headers. I do not want to hardcode the column headers in case I decide to upgrade the dictionaries at a later date.
I do not have sufficient knowledge yet to be able to do this.
I have tried various methods for the last few days but cannot seem to recover just the keys.
Any help really appreciated. Thank you.
jB
eg
ford = {'make': 'Ford', 'wheels': '4', 'colour': 'black'}
mahindra = {'make': 'Mercedes', 'wheels': '4', 'colour': 'white'}
reliant = {'make': 'Robin', 'wheels': '3', 'colour': 'rusty yellow'}
I can retrieve all the dictionaries data with a for items loop.
What I want to do is make list of just the keys from the first dictionary so that I can use it as column headers. I do not want to hardcode the column headers in case I decide to upgrade the dictionaries at a later date.
I do not have sufficient knowledge yet to be able to do this.
I have tried various methods for the last few days but cannot seem to recover just the keys.
Any help really appreciated. Thank you.
jB