I've the following text file taken from a csv file. The file is two long to be shown properly here, so here's the line info:
The file has 5 lines:
The 1st one starts in ETIQUETAS
The 2nd one stars in RECURSOS
The 3rd one starts in DATOS CLIENTE Y PIEZA
The 4th one starts in Numero Referencia,
The 5th and last one starts in BRIDA Al.
ETIQUETAS:;;;;;;;;;START;;;;;;;;;;;;;;;;;;;;;END;; RECURSOS:;;;;;;;;;0;0;0;0;0;0;0;0;0;1;0;0;0;0;0;0;1;1;1;0;1;0;;Nota: 0 equivale a infinito, para decir que no existen recursos usar un numero negativo
DATOS CLIENTE Y PIEZA;;;;PLAZOS Y PROCESOS;;;;;;;;;;hoja de ruta;MU;;;;;;;;;;;;;;;;;
Numero Referencia;Descripcion Referencia;Nombre Cliente;Codigo Cliente;PLAZO DE ENTREGA;piezas;PROCESO;MATERIAL;stock;PROVEEDOR;tiempo ida pulidor;pzas dia;TPO;tiempo vuelta pulidor;TIEMPO RECEPCION;CONTROL CALIDAD DE ENTRADA;TIEMPO CONTROL CALIDAD DE ENTRADA;ALMACEN A (ANTES DE ENTRAR MAQUINA);GRANALLA;TPO;LIMPIADO;TPO;BRILLADO;TPO;;CARGA;MAQUINA;SOLTAR;control;EMPAQUETADO;ALMACENB;TIEMPO;
BRIDA Al;BRIDA Al;AEROGRAFICAS AHE, S.A.;394;;;niquelado;aluminio;;;;matriz;;;5min;NO;;3dias;;;;;;;;1;1;1;;1;4D;;
I want to do two things:
- Count the between
STARTandENDof the first line, both inclusive and save it asTOTAL_NUMBERS. This means if I'veSTART;;ENDhas to count 3; theSTARTitself, the blank space between the two;;and theENDitself. In the example of the test,START;;;;;;;;;;;;;;;;;;;;;ENDit has to count22.
What I've tried so far:
f = open("lt.csv", 'r')
array = []
for line in f:
if 'START' in line:
for i in line.split(";"):
array.append(i)
i = 0
while i < len(array):
if i == 'START':
# START COUNTING, I DONT KNOW HOW TO CONTINUE
i = i + 1
2.Check the file, go until the word PROVEEDOR appears, and save that word and the following TOTAL_NUMBERS(in the example, 22) on an array.
This means it has to save:
final array = ['PROVEEDOR', 'tiempo ida pulidor', 'pzas dia, 'TPO', 'tiempo vuelta pulidor', 'TIEMPO RECEPCION', 'CONTROL CALIDAD DE ENTRADA', 'TIEMPO CONTROL CALIDAD DE ENTRADA, 'ALMACEN A (ANTES DE ENTRAR MAQUINA)', 'GRANALLA', 'TPO', 'LIMPIADO', 'TPO','BRILLADO','TPO','','CARGA', 'MAQUINA', 'SOLTAR', 'control', 'EMPAQUETADO', 'ALMACENB']
Thanks in advance.
1, if somebody could fix this I would appreciate it.ALMACENB;, is it discarded? Are you always going to stop atALMACENB;?PROVEEDORand endsTOTAL_NUMBERS(in the example,22) words after. You have that writen in question #2. Thanks in advance, Burhan.