Agreganto carpeta MenuRestaurante

master
Santiago 9 months ago
commit 7acfbc4b1d

@ -0,0 +1,45 @@
import threading
def leer_menu(tipo, archivo_entrada, archivo_salida):
try:
with open(archivo_entrada, 'r') as f:
lineas = f.readlines()
in_section = False
items = []
for linea in lineas:
if linea.startswith(f"{tipo}-"):
in_section = True
continue
elif in_section and linea.strip() == "":
in_section = False
continue
if in_section:
# Eliminar el número y guion del principio y agregar al resultado
plato = linea.strip()[len(f"{tipo}-"):]
items.append(plato)
print(f"El hilo {tipo} está escribiendo ... {plato}")
with open(archivo_salida, 'w') as f:
f.write('\n'.join(items))
except Exception as e:
print(f"Error: {e}")
# Crear los hilos
hilo_primeros = threading.Thread(target=leer_menu, args=(1, 'MenuRestaurante/menu.txt', 'MenuRestaurante/primeros.txt'))
hilo_segundos = threading.Thread(target=leer_menu, args=(2, 'MenuRestaurante/menu.txt', 'MenuRestaurante/segundos.txt'))
hilo_postres = threading.Thread(target=leer_menu, args=(3, 'MenuRestaurante/menu.txt', 'MenuRestaurante/postres.txt'))
# Iniciar los hilos
hilo_primeros.start()
hilo_segundos.start()
hilo_postres.start()
# Esperar a que todos los hilos terminen
hilo_primeros.join()
hilo_segundos.join()
hilo_postres.join()
print("Proceso completado.")

@ -0,0 +1,13 @@
1-PRIMEROS
1-Macarrones con tomate
1-Paella valenciana
...
2-SEGUNDOS
2-Cachopo asturiano
2-Chuletón gallego
...
3-POSTRES
3-Fruta del tiempo
3-Tarta de manzana
3-Cuajada con miel
...

@ -0,0 +1,10 @@
.
SEGUNDOS
Cachopo asturiano
Chuletón gallego
.
POSTRES
Fruta del tiempo
Tarta de manzana
Cuajada con miel
.

@ -0,0 +1,6 @@
.
POSTRES
Fruta del tiempo
Tarta de manzana
Cuajada con miel
.
Loading…
Cancel
Save

Powered by INFORMATICA.FP.EDU.ES.