Parsing files with python
<p>My input file is going to be something like this</p>

<pre><code>key "value"
key "value"
... the above lines repeat
</code></pre>

<p>What I do is read the file contents, populate an object with the data and return it. There are only a set number of keys that can be present in the file. Since I am a beginner in python, I feel that my code to read the file is not that good</p>

<p>My code is something like this</p>

<pre><code>ObjInstance = CustomClass()
fields = ['key1', 'key2', 'key3']

    for field in fields:
        for line in f:
            if line.find(field) &gt;= 0:
                if pgn_field == 'key1':
                    objInstance.DataOne = get_value_using_re(line)
                elif pgn_field == 'key2':
                    objInstance.DataTwo = get_value_using_re(line)

return objInstance;
</code></pre>

<p>The function "get_value_using_re" is very simple, it looks for a string in between the double quotes and returns it. </p>

<p>I fear that I will have multiple if elif statements and I don't know if this is the right way or not. </p>

<p>Am I doing the right thing here?</p>
