I was trying to dump User Posts from Mongo to Postgres while adding metadata for posts. I hit a couple errors when extracting metadata.
track_data = response["tracks"]["items"][0]
IndexError: list index out of range
KeyError: 'link'
KeyError: 'message'
We need to improve handling and add the functions inside try-except blocks to make sure program execution doesn't stop due to an invalid link or if data isn't available for a song. We could also use defaultdict to make sure we have a default values for keys in case data isn't present/parsed for a particular key.
I was trying to dump User Posts from Mongo to Postgres while adding metadata for posts. I hit a couple errors when extracting metadata.
We need to improve handling and add the functions inside
try-except
blocks to make sure program execution doesn't stop due to an invalid link or if data isn't available for a song. We could also usedefaultdict
to make sure we have a default values for keys in case data isn't present/parsed for a particular key.