gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
import os import glob import pandas as pd
- User
import os import glob import pandas as pd
- Assistant
Step 1: Create a list of all file paths
file_paths = glob.glob('/path/to/files/*.csv')
Step 2: Create an empty DataFrame
df = pd.DataFrame()
Step 3: Loop through the file paths and load each CSV file into a DataFrame
for file_path in file_paths: df_temp = pd.read_csv(file_path) df = pd.concat([df, df_temp], ignore_index=True)
Step 4: Save the combined DataFrame to a new CSV file
df.to_csv('/path/to/combined_file.csv', index=False)