How to generate a import file from .txt.

http://www.youtube.com/watch?v=b1e19u8K-CQ&feature=youtu.be

The PHP file:

<?php
$Content = "./easylist.txt";
$lines = file($Content);
$linesSplit = array_chunk( $lines, 2000 );
$badcharacters = array("#",'"', "'", "[", "]", "\n", "\t");

$i = 0;
foreach ($linesSplit as $inner_array) {
$i++;
$fp = fopen('ABimport'.$i.'.json', 'w');
$filestart = "[";
fwrite($fp, $filestart);
while (list($key, $value) = each($inner_array))
{
$cleanstr = str_replace($badcharacters, "", $value);
$store = '{"enabled":true,"string":"'.$cleanstr.'","javaClass":"com.untangle.uvm.node.GenericRule"},';
fwrite($fp, $store);
}
$fileend = "]";
fwrite($fp, $fileend);
fclose($fp);
}
?>

Read more in this thread.


Comments are closed.