File size: 1,646 Bytes
a080b32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# inspect_datafile.py (Versi dengan Path Lengkap)
import struct
import os

# --- KONFIGURASI ---
# Menggunakan path lengkap yang benar sesuai dengan struktur folder Anda
PATH_TO_DATAFILE = os.path.join(
    'data', 
    'Nuclear Cataract Database for Biomedical and Machine Learning Applications',
    'Nuclear Cataract Dataset',
    '01',
    'DER',
    'DATAFILE'
)

# --- SCRIPT UTAMA ---
try:
    with open(PATH_TO_DATAFILE, 'rb') as f:
        # Baca seluruh isi file dalam bentuk biner (bytes)
        content_bytes = f.read()

    print(f"--- Menganalisis File: {PATH_TO_DATAFILE} ---")
    print(f"Total ukuran file: {len(content_bytes)} bytes")
    print(f"Isi file dalam bentuk biner (raw bytes):\n{content_bytes}\n")

    # Mencoba membaca 4 byte pertama sebagai integer
    if len(content_bytes) >= 4:
        grade_as_integer = struct.unpack('<i', content_bytes[:4])[0]
        print(f"Interpretasi 4 byte pertama sebagai integer: {grade_as_integer}")

    # Mencoba membaca 8 byte pertama sebagai double (angka desimal)
    if len(content_bytes) >= 8:
        grade_as_double = struct.unpack('<d', content_bytes[:8])[0]
        print(f"Interpretasi 8 byte pertama sebagai double: {grade_as_double}")
        # Angka grade biasanya bilangan bulat, jadi kita bisa bulatkan
        print(f"Nilai double yang dibulatkan: {round(grade_as_double)}")


except FileNotFoundError:
    print(f"!!! ERROR: File tidak ditemukan di '{PATH_TO_DATAFILE}'")
    print("Pastikan semua nama folder di dalam path sudah benar dan tidak ada salah ketik.")
except Exception as e:
    print(f"Terjadi error: {e}")