• Register
1 vote


Hello guys, I have a big number of .csv file with full of data. I want to merge them all in a single file. It is a hectic job to copy all the data from each and compile into one single file. So, I am willing to combine multiple .csv files into one using a python program. Could anybody please help me to do it.

Thanks for your effort guys.

Note: I named all the .csv files under a series. Let say they are named with data1-data100

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote


Let me assume, you want to merge all the data from other files into the first file data1.csv file. So, you need to open the first file and then copy all the data from others and gather it into the first file.

for line in open("data1.csv"):
for num in range(2,100):
    f = open("data"+str(num)+".csv")
    for line in f:

GIve it a try and leave a comment below my answer if you have not overcome the problem.

13 9 6
94,240 points

Related questions

0 votes
1 answer 25 views
25 views asked Oct 24, 2020 Shaad Sh 800 points
0 votes
1 answer 21 views
I need to export my SQL information to a csv file so that I can attached this file to email. But the code below is not working. I have two main concerns. There is no line break even I used the “\n”. The exported csv file is empty. $servername = " ... ,time()).".csv"; $csv_file = fopen ($csv_filename, "w"); echo $csv_Content; fclose($csv_file); Please help me to make this code working.
asked Oct 23, 2020 azriel 590 points
0 votes
1 answer 12 views
Is there any PHP code snippet that demonstrate on how to import a csv file to MySql database?
asked Oct 22, 2020 azriel 590 points
0 votes
1 answer 16 views
I need to import a csv file that was generated by the system for me to import and save it to the database. But it generated an error “array_combine(): Both parameters should have an equal number of elements”. I was trying to debug my code but not able to see what cause ... $my_array[] = array_combine($keys, $data); } } fclose($csv); } /* if (($csv !== false) { }*/ return $my_array; }
asked Oct 12, 2020 robin_gallo 420 points
0 votes
1 answer 10 views
how to read csv file in matlab
asked Jan 25 waji 1.9k points
0 votes
1 answer 17 views
Question: How to select the csv file and then upload the content to mysql. Also, how to prevent the data from being duplicated in php. The field names of the csv is listed below. table: id name // cannot be duplicated talent // cannot be duplicated address email
asked Nov 2, 2020 RJ Lam 650 points
0 votes
1 answer 59 views
Hi, I need to save to my database from the csv file. My csv contains similar information in the code that I included here. "Last name", "First name", "SSN", "Test1", "Test2", "Test3", "Test4", "Final", "Grade" "Alfalfa", "Aloysius", "123-45-6789", 40.0, 90.0, 100.0, 83.0, 49.0, "D-" "Alfred", ... .0, 97.0, 96.0, 97.0, 48.0, "D+" "Gerty", "Gramma", "567-89-0123", 41.0, 80.0, 60.0, 40.0, 44.0, "C"
asked Oct 12, 2020 robin_gallo 420 points
0 votes
1 answer 32 views
Problem: How Open CSV file using FileReader object? How Create BufferedReader from FileReader? How Read file line by line using readLine() method?
asked Nov 6, 2020 Mashhoodch 9.1k points
0 votes
1 answer 20 views
Problem: Hello guys, While working on file handling in python, I know the basic operation like how to open a file, how to read a file, update a file in python but I want to use python file to open multiple file but don't know how to do this. The syntax to open a file object: file_object = open(“filename”, “mode”)The syntax to close the file: file.close()
asked Jun 10, 2020 Gavin 15.3k points
0 votes
1 answer 25 views
Problem: I need a quick PHP code that will export my records to a csv file. The fields in the record includes the item_id, item_name, item_description, item_price, item_qty. I needed these headers included in the csv.
asked Oct 31, 2020 RJ Lam 650 points