kosheev_maksim_lab_2 is ready

This commit is contained in:
m1aksim1 2024-11-11 23:34:00 +04:00
parent 3b9698ac38
commit 20acae9135
9 changed files with 38 additions and 0 deletions

View File

View File

View File

@ -0,0 +1,11 @@
# Используем Python-образ
FROM python:3.9
# Копируем скрипт генерации данных
COPY generate_data.py /app/generate_data.py
# Устанавливаем рабочую директорию
WORKDIR /app
# Запускаем скрипт
ENTRYPOINT ["python", "generate_data.py"]

View File

View File

View File

View File

@ -0,0 +1,11 @@
# Используем образ Python
FROM python:3.9-slim
# Создаем рабочий каталог
WORKDIR /app
# Копируем скрипт в контейнер
COPY main.py .
# Команда для запуска программы
CMD ["python", "main.py"]

View File

@ -0,0 +1,16 @@
import os
input_dir = '/var/data'
output_file = '/var/result/data.txt'
def get_first_line_from_files(input_directory, output_path):
with open(output_path, 'w') as outfile:
for filename in os.listdir(input_directory):
file_path = os.path.join(input_directory, filename)
if os.path.isfile(file_path):
with open(file_path, 'r') as infile:
first_line = infile.readline().strip()
outfile.write(first_line + '\n')
if __name__ == "__main__":
get_first_line_from_files(input_dir, output_file)