Combine Multiple CSV Files
- Download the results from your requests here
- Create a new directory on your local computer. All CSV files in the directory should be the same request type (ex: "stock-page").
- 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()
Updated 7 months ago
What’s Next