import os
import glob
import pandas as pd

import matplotlib.pyplot as plt

def plot_csv_files_in_directory(directory):
    """
    Loads all CSV files in the given directory and creates a plot for each file.
    Assumes all CSV files have two columns. The plot title is the base filename.

    Parameters
    ----------
    directory : str
        Path to the directory containing CSV files.

    Returns
    -------
    None
    """
    csv_files = glob.glob(os.path.join(directory, "*.csv"))
    for csv_file in csv_files:
        df = pd.read_csv(csv_file)
        if df.shape[1] != 3:
            continue  # Skip files that do not have exactly two columns
        plt.figure()
        
        plt.plot(df.iloc[:, 0], df.iloc[:, 1])
        plt.title(os.path.splitext(os.path.basename(csv_file))[0])
        plt.xlabel('Column 1')
        plt.ylabel('Column 2')
        plt.tight_layout()
    plt.show()

if __name__ == "__main__":
    plot_csv_files_in_directory("./csvs")