Skip to content

Instantly share code, notes, and snippets.

@adamcameron
Created February 14, 2025 12:57
Show Gist options
  • Save adamcameron/0009f5e52eb99e6d34a293a0d19fb098 to your computer and use it in GitHub Desktop.
Save adamcameron/0009f5e52eb99e6d34a293a0d19fb098 to your computer and use it in GitHub Desktop.
dediff.php
<?php
$fromLive = fopen('../var/tmp/from_live.csv', 'r');
$fromTest = fopen('../var/tmp/from_test.csv', 'r');
$fromLiveSame = fopen('../var/tmp/from_live_same.csv', 'w');
$fromTestSame = fopen('../var/tmp/from_test_same.csv', 'w');
$fromLiveDiff = fopen('../var/tmp/from_live_diff.csv', 'w');
$fromTestDiff = fopen('../var/tmp/from_test_diff.csv', 'w');
while (($lineLive = fgets($fromLive)) !== false) {
$lineTest = fgets($fromTest);
if ($lineTest === false || trim($lineLive) !== trim($lineTest)) {
fwrite($fromLiveDiff, $lineLive);
if ($lineTest !== false) {
fwrite($fromTestDiff, $lineTest);
}
} else {
fwrite($fromLiveSame, $lineLive);
fwrite($fromTestSame, $lineTest);
}
}
while (($lineLive = fgets($fromLive)) !== false) {
fwrite($fromLiveDiff, $lineLive);
}
fclose($fromLive);
fclose($fromTest);
fclose($fromLiveSame);
fclose($fromTestSame);
fclose($fromLiveDiff);
fclose($fromTestDiff);
echo "Comparison complete.\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment