Welcome to the "Web Projects" forums. Before you post, make sure you've selected the correct category based on the size of your project (in US dollars), or whether it is a partnership or "looking for work" request instead. Observe the guidelines for this section:
To all thread starters, check your "pm" box for responses, as that's how bidders will be communicating with you mainly using. You can turn on new pm notification by going to "User CP"-> "Edit Options"-> "Receive Email Notification of New Private Messages".
To respondents, avoid replying to a thread with a short generic response like "pm sent" as much as possible. It is pointless and clutters up the screen.
To respondents, don't reply to a work request with a summary of your resume. If you're not willing to spend the time to at least read the request and respond specifically to the request, then don't reply. The Web Projects forum isn't a place to get your resume/ portfolio posted on as many threads as possible, it's for the direct, human interaction between coder and client. Members who blanket the forums with their resume replies will be treated as spammers and banned.
To all thread starters, please update your thread's prefix to "resolved", when you've found a coder for your project or partnership (or wish to terminate the request). This is so coders don't waste time bidding on an invalid project. To do this, click on the "Edit" button under the first post of the thread, then the "Go Advanced" button. You have 14 days to update your thread's title.
I have edited out confidential information and replaced with field names..
As you can see the end numbers are the membership numbers, both files contain those at the end of each line, i need the ones that match to be combined/merged into one line and put into an output file
OK, this script below should do the job that is assuming the following:
1 - the files with content are exactly as you have describe with no other header lines or anything out of place
2 - the file are readable and in the same drectory as this script
3 - you hold your mouth at just the right angle when pushing the button
anyway... this is a first test... let me know how it goes.
PHP Code:
<?php /* put this script in the same directory as the two files and put the file names in below. */ // enter the file names here $file1 = 'file-1.txt'; $file2 = 'file-2.txt';
$data1 = filetoarray($file1,6); // you can actually specify the column the id is in if it's different in each file... although it seems to be the same from your dataset extract... at column 6 $data2 = filetoarray($file2,6);
// now loop through one of the datasets and match the keys with the other // build the keys list $dataSetKeys = array_keys($data1); // loop through the keys and build the results $j = count($dataSetKeys); for($i = 0; $i < $j; $i++){ $thisKey = $dataSetKeys[$i]; if(isset($data2[$thisKey])){ echo $data1[$thisKey][0].','.$data1[$thisKey][1].','.$data1[$thisKey][2].','.$data1[$thisKey][3].','.$data1[$thisKey][4].','.$data1[$thisKey][5].','.$data2[$thisKey][0].','.$data2[$thisKey][1].','.$data2[$thisKey][2].','.$data2[$thisKey][3].','.$data2[$thisKey][4].','.$data2[$thisKey][5]."<br>"; } } // "id","members name","access code","expiration","pin","704241" "address","city","state","","zip","704241"
// functions... function filetoarray($file,$idKeyCol){ $rawData1 = file_get_contents($file); return cleanlines($rawData1,$idKeyCol); }
function cleanlines($data,$idKeyCol){ // expand it at the linebreaks $newData = explode("\n",$data); $cleanData = array(); $j = count($newData); for($i = 0; $i < $j; $i++){ $thisParts = explode(",",$newData[$i]); $cleanData[$thisParts[$idKeyCol-1]] = $thisParts; } return $cleanData; } ?>