I'm trying to convert key value pairs from a csv file to a dictionary. I've used csv reader and also tried doing it manually using python alone. For some reason, whenever I print out the dictionary, it only outputs the final line. I've even tried creating separate test lists and reloaded my notebook but I still only get the final line. This is my testing code
listOfStrings = ['Hi'] * 300 # CSV file has about 300 lines
listOfNum = [5] * 300
myDict=dict(zip(listOfStrings, listOfNum))
print(myDict)
I only get
{'Hi':5}
But when I print listOfStrings
and listOfNum
I get the full output of 300 in each list.
Things like this work:
listOfStrings = ['Hi', 'Hello']
listOfNum = [5, 6]
myDict=dict(zip(listOfStrings, listOfNum))
print(myDict)
{'Hi': 5, 'Hello': 6}