2
I’m new to Python and I have a problem that’s getting me out of the picture...
Here’s the thing, I want to get the strings of a file and compare its elements with the sentences written in the spreadsheets of my archive .xlsx. 
Only that the strings of the file will have what is written in the spreadsheet plus some codes.
I want the program to do the following: If in the file line you have what is in the column I am going through do the instruction else, jump to the next line.
Follows the code:
#!/usr/bin/python
import subprocess
import xlrd
arquivo = open("/home/weslei/Documentos/t.txt", "r")
read = arquivo.readlines()
xls = xlrd.open_workbook('chips.xlsx')
plan = xls.sheets()[0]
b =  plan.col(0)
for i in read:
   for n in b:
       if n == i[20:57]:
           print "instrucao"
       else:
           print "next"
The file I’m reading has this content:
|7891515433963     |AMENDOIM SEM PELE MANIX 40G          |UN|34119/6|AF  4,9900|
|7897846301872     |AREIA HIG ABSORCAT             4KG   |UN|32306/2|AF  7,9900|
|7898948468012     |ARROZ CARRIJO TIPO1            5KG   |UN|32471/7|AF 13,8000|
|7896290300974     |ARROZ PRATO FINO ORGAN INTEG 1K UN   |UN|33908/7|AF 14,9500|
|7896290300318     |ARROZ PRATO FINO PARBOLIZADO   2KG   |UN|32034/4|AF  8,7500|
|7896290300295     |ARROZ PRATO FINO PARBOLIZADO 1K UN   |UN|32185/3|AF  4,3900|
|0000000000000     |ARROZ PRATO RICO AGULINHA 5KG        |UN|34335/0|AF  0,0000|
And the spreadsheet:
ELMA CHIPS  
AMENDOIM SEM PELE MANIX 40G 1,79
BACONZITOS 55G  3,68
*BACONZITOS 110G    6,15
*BATATA SENSAÇÃO FG.GRELH. 90G  6,15
*CEBOLITOS 60G  3,68
*CEBOLITOS ASSADO 110G/120G 6,49
*CHEETOS 51G/ 55G/57G/59G/61G    2,49 
*CHEETOS  130G/150G/160G    6,28
*DEMONTÃO RUFLES BACON. 75G 4,45
*DORITOS 55G    3,65
*DORITOS QUEIJO 96G/110G/100G   6,25
*DORITOS QUEIJO NACHO 167GR 9,98
*DORITOS  200G/220G 9,98
*FANDANGOS 63G   2,45 
*FANDANGOS PRESUNTO/QUEIJO 175G 6,25
*FANDANGOS PRESUNTO 164GR   6,25
*PANETINI PRESUNTO / QUEIJO 40G 1,89
*PINGO D'OURO 65G   2,99
*PINGO D'OURO 90G   3,68
*RUFFLES 90G/100G   6,15
RUFFLES 96GR    6,15
*RUFFLES 175G    9,98 
*RUFFLES 57/50G  3,50 
*SALGADINHOS TORCIDA 60/50G 1,75
Detail: The program outputs the columns as text:u'*SALGADINHOS TORCIDA 60/50G', all columns come out with the text:u, causing the pq iteration error in the file has no text:u.
What version of Python? and how are you emitting the output?
– stderr
Python 2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609] on Linux2
– Weslei