TFMUOC / utils.py
JoseAntonioBarrancoBernabe's picture
Primera subida ficheros de la app
0b7778d verified
raw
history blame
812 Bytes
import os
#import streamlit as st
import tempfile
#donde se almacenan los ficheros subidos por usuario
FILE_LIST = "ficheros.txt"
#funcion para cargar ficheros
def load_name_files(path):
archivos = []
with open(path, "r") as file:
for line in file:
archivos.append(line.strip())
return archivos
#informa nombres de ficheros a ser almacenados
def save_name_files(path, new_files):
old_files = load_name_files(path)
with open(path, "a") as file:
for item in new_files:
if item not in old_files:
file.write(item + "\n")
old_files.append(item)
return old_files
#limpieza de los ficheros
def clean_files(path):
with open(path, "w") as file:
pass
return True