I have a text file with the following content in it
last name, first name, email, some arbitrary id number, and a phone number.
Hill, Jonah, [email protected], 015666, 123-456-7890
Reynolds, Ryan, [email protected], 1081254, 789-456-1230
Baccarin,Morena, [email protected], 1011340, 159-753-4561
...
I want to make a dictionary for each row, but have keys to name such as last name, firstname etc.
here's the code I'm trying
d = {}
with open("oldFile.txt") as f:
d = dict(x.rstrip().split(None, 1) for x in f)
print d
I get something like this with all the content in the file in one whole dictionary
{'"hil"': '"jonah" "jonahhill@outlook" "015666" "123-456-7890"'...}
The results I'm looking for is
First person:
{lastname: "hill" , firstname: "Jonah", email: "[email protected]...}
Second person:
{Reynolds, Ryan, [email protected], 1081254, 789-456-1230}
Third person: ...
I want keys to print them out individual such as
in file1 print out first person and I get
First person:
{lastname: "hill" , firstname: "Jonah", email: "[email protected]...}