I'm trying to merge all the csv or tsv files in a drectory (only one type at a time) into a "merge".csv or .tsv, plus insert the source file name as the first field in each record.
By inserting that field it seems to mess up the formatting of the csv or tsv data. See sample files and outputs attached.
**Note: in the attached files all of the tsv files have been renamed to .jpg since expert-exchange won't allow uploading tsv files!?!?
$path='C:/Documents and Settings/Steve/My Documents/a_Holijoli/a_Projects/TCH-Group/SampleFiles/';
$pathdir = opendir($path);
$outFile = "$path merge.csv";
$fout = fopen($outFile, 'w');
while (false !== ($file = readdir($pathdir)))
if(stristr($file, '.csv') == TRUE)
echo "...> $fullname<br/>";
$recArr = file("$fullname");
foreach($recArr as $rec)