I am reading a .dat file (supposed csv) to convert the data to json. Long story short I can't use source code from others cause the format of the data in the first half of the file is awkward and I needed to handle for that as well.
Now that I'm hitting the correct format for csv (one row of key's, and the following rows with values in the order of the keys) I am having a hard time putting them together. I get the keys just fine by splitting the line by (',') and by splitting, it stores in a list.
I can get the next line as well, by splitting and storing that line in a list.
Now comes the 2 questions.
- How do I match the value with the keys in the 2 lists? Ex.
List 1 = [Q1, Q2, Q3]
List 2 = [A1, A2, A3]
I want the result to look like
dict = {'Q1':'A1', 'Q2':'A2', 'Q3':'A3'}
- How do I handle multiple lines of values? Everything is in a loop so when it hits the second line of values, it just overwrites the previous answers