None
TL
TIL Simple Merge of two CSVs with Python
[]
matduggan.com
import pandas as pd import os # Define the filenames file_one = 'one.csv' file_two = 'two.csv' output_file = 'combined_report.csv' # Define the column names to use for joining # These should match the headers in your CSVs exactly deploy_join_col = 'Deployment Name' stacks_join_col = 'name' try: # Check if input files exist if not os.path.exists(file_one): raise FileNotFoundError(f"Input file not found: {file_one}") if not os.path.exists(file_two): raise FileNotFoundError(f"Input file not found: {file_two}") # Read the CSV files into pandas DataFrames print(f"Reading {file_one}...") df_deploy = pd.read_csv(file_one) print(f"Read {len(df_deploy)} rows from {file_one}") print(f"Reading {file_two}...") df_stacks = pd.read_csv(file_two) print(f"Read {len(df_stacks)} rows from {file_two}") #…