Combine Multiple CSV Files

  1. Download the results from your requests here
  2. Create a new directory on your local computer. All CSV files in the directory should be the same request type (ex: "stock-page").
  3. Ensure you have pandas installed pip install pandas and run the following Python script in a Jupyter Notebook.
import os
import pandas as pd
import glob


def load_csv_files(directory: str) -> pd.DataFrame:
    """Load all CSV files in a directory into a single DataFrame."""
    files = glob.glob(os.path.join(directory, "*.csv"))

    dataframes = []
    for file in files:
        df = pd.read_csv(file)
        dataframes.append(df)

    return pd.concat(dataframes, ignore_index=True)

directory_path = "sample_data" # replace with your directory path

df = load_csv_files(directory_path)
df.head()