Iterate in 2 different dictionaries simultaneously in Python
<p>---EDIT 2---
So I get the question Why I use dictionaries?,
this question is a follow up on this one:  <a href="https://stackoverflow.com/questions/38647250/csv-file-compression-without-using-existing-libraries-in-python/38662750#38662750">csv file compression without using existing libraries in Python</a></p>

<p>I Need to compress a 500k csv file (19MB), and I chose to use dictionary to store the ticks in one csv file and symbs in another to be able to Decompress the values </p>

<p><strong>QUESTION</strong>: How do I iterate the most optimized way? this is just an example of 4 rows, but my real file has 500 000 lines, and takes me for ever to iterate through the list.</p>

<p>I have 3 dictionaries:</p>

<pre><code>originalDict = {
               0: ['6NH8', 'F', 'A', '0', '60541567', '60541567', '78.78', '20'], 
               1: ['6NH8', 'F', 'A', '0', '60541569', '60541569', '78.78', '25'], 
               2: ['6AH8', 'F', 'B', '0', '60541765', '60541765', '90.52', '1'], 
               3: ['QMH8', 'F', 'B', '0', '60437395', '60437395', '950.5', '1']
               }
ticks = {0: '6NH8', 1: '6AH8', 2: 'QMH8'}
symbs = {0: 'F,A', 1: 'F,B'}
</code></pre>

<p>I want to iterate through originalDict and change the "ticks" and then the symbs at <code>index 1</code> and <code>index 2</code> and then remove <code>index 2</code></p>

<p>so, i.e. </p>

<pre><code>0: ['6NH8', 'F', 'A', '0', '60541567', '60541567', '78.78', '20']
</code></pre>

<p>becomes:</p>

<pre><code>[0, '0', '0', '60541567', '60541567', '78.78', '20']
</code></pre>

<p>I have currently a for loop going through values in originalDict, and inside that another for loop:</p>

<pre><code>for values in originalDict.values():
    for ticksKey, ticksValue in ticks.items():
        if values[0] == ticksValue:
            values[0] = ticksKey

    #Change symbs and remove char combination
    for symbsKey, symbsValue in symbs.items():
        comprComb = values[1] + "," + values[2]

        if comprComb == symbsValue:
            values[1] = str(symbsKey)
            #del values[4]
            #del values[4]
            del values[2]
</code></pre>

<p>ADDITIONAL INFO ADDED:
The reason I have them as dictionary is because the 500 000 lines, some of the ticks occurs more than once, so, I give them a int which is the key in the dict, so goes for the symbs dictionary too. </p>