DB 경로

DB_CONFIG = { "host": "localhost", "port": 5432, "dbname": "postgres", "user": "postgres", "password": "",}

스키마 : c1_fct_detail , 테이블 : fct_detail → 로 없으면 만들어서 저장, 있으면 데이터 update방식

  1. 경로 : C:\Users\user\Desktop\machinlog\FCT\yyyy\mm\dd

    1-1) yyyy → 년도, mm → 월, dd → 날

    1-2)반드시 위의 형식에 맞는 경로 안의 폴더들의 파일들이 대상

    예시) C:\Users\user\Desktop\machinlog\FCT\2025\10\01 → 안의 FORD A+C PD FULL 35915729 또는 다른 폴더 안의 파일들이 대상

  2. 파일 폴더 이름에 ‘PD’가 있으면 컬럼 remark의 속성값으로 ‘PD’ 삽입

    파일 폴더 이름에 ‘PD NONE’가 있으면 컬럼 remark의 속성값으로 ‘Non-PD’ 삽입

  3. 파일 명 형식 : (barcode)yyyymmdd(start time).txt

    3-1)컬럼 barcode_information의 속성값으로 (barcode) 삽입

    3-2)컬럼 end_day의 속성값으로 yyyymmdd

    단, 컬럼 end_time의 속성값 조건(4-5번) 의해 yyyymmdd + 1일 일수 있음

  4. 파일 내용 형식 : [hh:mm:ss.ss] (내용)

    ANSI 형식임

    4-1)컬럼 test_time의 속성값으로 ‘[]’는 제외하고 hh:mm:ss.ss 를 삽입

    → VARCHAR(12) 형식을 저장

    4-2) 컬럼 barcode_inforamtion의 속성값 별로 컬럼 test_ct의 속성값으로 현재행의 test_time의 속성값 - 이전행 test_time의 속성값의 계산값이 초단위로 들어갈 것, 첫 행은 이전행이 없으므로 컬럼 test_ct의 속성값은 null, test_ct가 음수가 나오는 케이스(자정 넘김)도 파일 내부에서 보정(예: +86400)

    4-3) (내용)은 최대 80자까지 허용하여 컬럼 contents의 속성값으로 들어갈 것

    4-4) 위의 형식 외의 내용은 제외

    예시)

    /proc/bus/usb/devices not found - trying /sys → 제외 Found USB2 plug PMU3A32I speed: 480 at 1:2 → 제외 Connecting [Serial: PMU3A32I] → 제외

    4-5) 컬럼 end_time에 제일 마지막 행 [hh:mm:ss.ss]를 속성값으로

    → 단, ‘[]’는 제외하고 소수점 첫번째를 반올림 하여 ‘hh:mm:ss’ 를 삽입

  5. 컬럼 file_path 는 파일 경로을 넣을 것

  6. 첨부파일과 같이 컬럼 [barcode_information, remark, end_day, end_time, contents, test_ct, test_time, file_path] 순서로 dataframe 저장될 것

    barcod_information remark end_day end_time contents test_ct test_time file_path
  7. 재실행 시 컬럼 file_path 속성값을 체크해서 중복 시 데이터 처리하지 말고pass할 것

  8. console에 아래의 예시와 같이 표시되도록 수행 명령

C:\Users\user\PycharmProjects\PythonProject\.venv\Scripts\python.exe C:\Users\user\PycharmProjects\PythonProject\d1\d1_FCT_machine_log.py [INFO] Connection String: postgresql+psycopg2://postgres:leejangwoo1%21@localhost:5432/postgres [INFO] Table ensured: d1_machine_log."FCT1_machine_log" [INFO] Table ensured: d1_machine_log."FCT2_machine_log" [INFO] Table ensured: d1_machine_log."FCT3_machine_log" [INFO] Table ensured: d1_machine_log."FCT4_machine_log" [INFO] Scan folder: C:\Users\user\Desktop\machinlog\FCT\2025\08 [INFO] Scan folder: C:\Users\user\Desktop\machinlog\FCT\2025\09 [INFO] Scan folder: C:\Users\user\Desktop\machinlog\FCT\2025\10 [INFO] Scan folder: C:\Users\user\Desktop\machinlog\FCT\2025\11 [INFO] Target files: 391 [INFO] Multiprocessing enabled: processes=11, chunksize=10