How to merge multiple CSV files in to one csv files in PHP or joomla?
Merge all data from the csv files in a folder into a text file with a few small changes you can also use this for txt files. Replace *.csv for *.txt
How to merge multiple CSV files in to one csv files in PHP or joomla?
Merge all data from the csv files in a folder into a text file with a few small changes you can also use this for txt files. Replace *.csv for *.txt
To do this in PHP you would do something in the lines of:
Ex.
$csvdir = './csvdir';
$result = fopen('./merge.csv', 'w');
if ($handle = opendir($csvdir)) {
while (false !== ($entry = readdir($handle))) {
if (substr($entry, -4) === ".csv") {
$csvcontent = file_get_contents($entry);
fwrite($result, $csvcontent);
}
}
closedir($handle);
}
fclose($result);
Merge all data from the csv files in a folder into a text file
Note: with a few small changes you can also use this for txt files. Replace *.csv for *.txt
1) Windows Start Button | Run 2) Type cmd and hit enter ("command" in Win 98) 3) Go to the folder with the CSV files (for help how to do that enter "help cd") 4) Type copy *.csv all.txt and hit enter to copy all data in the files into all.txt. 5) Type exit and hit enter to close the DOS window
Now we must import the text file all.txt into Excel.
1) Open Excel 2) When you use File Open to open all.txt the Text Import Wizard will help you import the file 3) Choose Delimited 4) Next 5) Check Comma 6) Finish