<commit_before>#!/usr/bin/php
<?
function usage () {
	echo "Usage: merge.php hostip.csv add.csv\n";
	exit (1);
}

function arrange ($f) {
	$_f = file ($f);

	foreach ($_f as $v ) :
		$v = trim ($v);
		$_v = explode ('|', $v);
		$_r[$_v[0]] = $v;
	endforeach;

	return $_r;
}

if ( $argc != 3 ) :
	usage ();
endif;

if ( ! file_exists ($argv[1]) ) :
	echo "hostip.csv   ʽϴ.\n";
	exit (1);
endif;

$hostip = $argv[1];

if ( ! file_exists ($argv[2]) ) :
	echo "߰   ʽϴ.\n";
	exit (1);
endif;

$addip = $argv[2];

# hostip  迭 
$r_hostip = arrange ($hostip);
$r_addip = arrange ($addip);

foreach ($r_addip as $k => $v ) :
	$r_hostip[$k] = $v;
endforeach;

natsort ($r_hostip);

foreach ( $r_hostip as $v ) :
	echo $v."\n";
endforeach;

?>
<commit_msg>added working line to stderr<commit_after>#!/usr/bin/php
<?
function usage () {
	global $stderr;

	fprintf ($stderr, "Usage: merge.php original.data attached.data\n");
	fclose ($stderr);
	exit (1);
}

function arrange ($f) {
	global $stderr;
	$p = fopen ($f, 'rb');

	$i=0;
	while ( ! feof ( $p) ) :
		fprintf ($stderr, "  ==> %d\r", ++$i);
		$buf = trim (fgets ($p));
		$v = explode ('|', $buf);
		$_r[$v[0]] = $buf;
	endwhile;
	fprintf ($stderr, "\n");

	fclose ($p);
	
	return $_r;
}

$stderr = fopen ('php://stderr', 'w');

if ( $argc != 3 ) :
	usage ();
endif;

if ( ! file_exists ($argv[1]) ) :
	fprintf ($stderr, "original data (%s)   ʽϴ.\n", $argv[1]);
	fclose ($stderr);
	exit (1);
endif;

$hostip = $argv[1];

if ( ! file_exists ($argv[2]) ) :
	fprintf ($stderr, "߰ (%s)  ʽϴ.\n", $argv[2]);
	fclose ($stderr);
	exit (1);
endif;

$addip = $argv[2];

# hostip  迭 

# hostip array 
fprintf ($stderr, "* Get Original data (%s)\n", $hostip);
$r_hostip = arrange ($hostip);
$l['r_hostip'] = count ($r_hostip);
fprintf ($stderr, "* Get Attched data (%s)\n", $addip);
$r_addip = arrange ($addip);
$l['r_addip'] = count ($r_addip);

fprintf ($stderr, "* Merge Attached data (%d)\n", $l['r_addip']);
$i = 0;
foreach ($r_addip as $k => $v ) :
	fprintf ($stderr, "  ==> %d\r", ++$i);
	$r_hostip[$k] = $v;
endforeach;
fprintf ($stderr, "\n");
$l['merged'] = count ($r_hostip);

fprintf ($stderr, "* Sort Merged data (%d)\n", $l['merged']);
natsort ($r_hostip);

fprintf ($stderr, "* Record Data (%d)\n", $l['merged']);
$i = 0;
foreach ( $r_hostip as $v ) :
	fprintf ($stderr, "  ==> %d\r", ++$i);
	echo $v."\n";
endforeach;
fprintf ($stderr, "\n");

fclose ($stderr);
?>

{'fraction_non_alphanumeric': 0.2547638773819387, 'fraction_numerical': 0.009527754763877383, 'mean_word_length': 3.7916666666666665, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3591697', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1069, 'n_words': 268}