0

I have several CSV files (tables) in a directory (all tables have different schemas) and want to loop over the files and read each table into a separate dataframe.

Is there any way to do this in Python/Pandas - to read the different tables into a dataframe array? How multiple tables (with different schema) be imported into a multiple separate data frames?

4

1 回答 1

1

try this;

import os
import pandas as pd
import glob
os.chdir("E:/") # change this to the directory where your csv files are stored
csv_files = {} # we store the dataframes in a dictionary
for file in glob.glob("*.csv"): 
    csv_files[file] = pd.read_csv(file)

for dataframe in csv_files.values():
    print dataframe
于 2013-08-08T12:21:46.780 回答