Hi I'm looking to load a plain text file that has lines of text (conversations) into a dictionary. So for example, I have these lines in a .txt file (each could be separated by a new line)
This is line one.
This is line two.
So I'd want to be able to load these into a dict and end up with { "1":"This is line one." , "2":"This is line two." }
and have the keys just be the line numbers so I can reference them using dict["1"]
, etc.
I can load a text file into a dictionary using parse_json but I had to preformat those lines manually first, obviously not ideal.
How would I go about doing something like this? Thanks.