Question: Hello Experts I have multiple files generated using Dataframes . These are placed in /tmp path as input1.csv , input2.csv, input3.csv and goes on .

Hello Experts

I have multiple files generated using Dataframes . These are placed in /tmp path as

input1.csv , input2.csv, input3.csv and goes on .

If the below code is used , it gives me an error stating "ValueError: No objects to concatenate" . If i place the files manually , the code works with concat logic .

However when i run the entire logic - before my process creates the csv files , it tries to concatenate and shows the above error . Any suggestions how to handle this case ?

import pandas as pd import glob path = "/tmp" # use your path all_files = glob.glob(path + "/*.csv") li = [] for filename in all_files: df = pd.read_csv(filename, index_col=None, header=0) li.append(df) frame = pd.concat(li, axis=0, ignore_index=True) 

How do we ensure before running

frame = pd.concat(li, axis=0, ignore_index=True) 

step , the .csv files are checked to be present and then concatenate

Note : Continuation question from https://www.coursehero.com/qa/wait/31264255/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!