How to create a loop, that goes through every row until the current value is not equal to the previous
<p>I have such excel document, with the list of product id's. I need to create an array of evaluation.</p>

<p><a href="http://i.stack.imgur.com/RXrSt.png" rel="nofollow"><img src="http://i.stack.imgur.com/RXrSt.png" alt="enter image description here"></a></p>

<p>So,my algorithm is follow:
1) While current product id value is equal to previous one add an evaluation value to product array
2) When current product id is not equal to previous one - create a new product array. </p>

<p>I'm using openpyxl to get an access to xlsx files.
But my loop is not working incorrect, going infinitely. </p>

<pre><code>import openpyxl
import os
import glob
from openpyxl import load_workbook
from openpyxl import Workbook

file =  load_workbook("Snippet_output.xlsx")
work_sheet = file.active


for row_num in range (3, 28):
    query = str(work_sheet.cell(row = row_num, column= 6).value)
    query_prev = str(work_sheet.cell(row = row_num-1, column= 6).value)
    evaluation = str(work_sheet.cell(row = row_num, column= 9).value)
    eval_list = []
    while True:
        eval_list.append(evaluation)
        if query == query_prev:
            break

print(eval_list)
</code></pre>

<p>Can you help me with a loop
My output should look like, 
eval_list1 = [3,2,1,2,3,2,1,2,3,1]
eval_list2 = [1,3,2,1,2,3,2,3,1,1]
etc</p>

<p>I am not sure what you try to do exactly.  I'll guess something like (warning: untested!):</p>

<pre><code>START_ROW, END_ROW = 3, 27
eval_list = []
previous_id = str(work_sheet.cell(row=START_ROW-1, column=6).value)
for row_num in range (START_ROW, END_ROW+1):
  current_id = str(work_sheet.cell(row=row_num, column=6).value)
  current_result = str(work_sheet.cell(row=row_num, column=9).value)
  if current_id == previous_id:
    eval_lost.append(current_result)  # same ID, continue appending
  else:
    print (eval_list)    # different ID, print previous list 
    eval_list = []     # start new empty list for next ID
  previous_id = current_id  # update for next iteration
print (eval_list)        # 
</code></pre>

<p>N.b. your question did not specify python2 or python3, use parenthesis in prints according to python version.</p>

<p>Good luck!</p>

python openpyxl