1

There are 40 csv files; file1.csv, file2.csv. ..., file40.csv in a folder called pathImage. I want to read them, and put them in another csv file sequentially that we called 'output.csv'. The following code does not work for me.

im_list=[]
for i in pathImage:
    f= open(i, 'rb') 
    reader = csv.reader(f, delimiter=',')
    header = reader.next()
    zipped = zip(*reader)
    for j in zipped[0]:       #zipped[0] is the name of images
        im_r=misc.imread("%s.png" %j)
        im_list.append(im_r)

I already read the previous questions, but I do not know how can I put them into another csv file?

I appreciate any help

1 Answer 1

0
import pandas as pd
df = pd.concat([pd.read_csv('file%d.csv' % x) for x in range(1,41)])
df.to_csv('output.csv')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.