import pandas as pd

# Load the full CSV (with all columns)
df = pd.read_csv("in/df_suppressed.csv", encoding='UTF-8', on_bad_lines='skip', delimiter=';')  # or 'cp1252' if needed

# Replace "X" and "Y" with your actual column names if needed
x_col = 'Lambert_X'
y_col = 'Lambert_Y'

# Ensure X and Y are numeric, coerce invalid to NaN
df[x_col] = pd.to_numeric(df[x_col], errors='coerce')
df[y_col] = pd.to_numeric(df[y_col], errors='coerce')

# Interpolate only the X and Y columns (other columns untouched)
df[[x_col, y_col]] = df[[x_col, y_col]].interpolate(method='linear', limit_direction='both')

# Save to a new CSV
df.to_csv("out/interpolated_trace.csv", index=False, sep=';')

print("✅ Interpolation done on X/Y. Other columns preserved.")
