parsing key file

Jose Lerebours fpgroups at gmail.com
Tue May 25 11:45:47 PDT 2021


Ah, and given that wonderful and valuable piece of information, the 
following script (PHP) renders a nice and clean table

$key ="csv/key";
$map ="csv/map";
$file =file_get_contents($map);
$rows =explode(chr(10),$file);
list($a,$blocksize,$b,$fields,$pwd,$b)=explode(":",$rows[0]);
$cols =[];$n=0;
for($x=1;$x<sizeof($rows);$x++){
if(!isset($rows[$x])){continue;}
if(sizeof(explode(":",$rows[$x]))<3){continue;}
list($aa,$ab,$ac)=explode(":",$rows[$x]);
if(intval($ab)<1){continue;}
$cols[$n]['name']=$aa;
$cols[$n]['size']=intval($ab);
$n++;
}
$maxsize =filesize($key);
$sent =0;
$handle =fopen($key,"r");
echo"<table border=1>";
echo"<thead><tr>";
for($x=0;$x<sizeof($cols);$x++){
echo"<th>{$cols[$x]['name']}</th>";
}
echo"</tr></thead><tbody>";
while($sent <$maxsize){
$row =fread($handle,$blocksize+20);
$row =substr_replace($row,'',0,20);
if(trim($row)==""){$sent +=$blocksize;continue;}
$p =0;$record ="";
for($x=0;$x<sizeof($cols);$x++){
$record .="<td>".substr($row,$p,$cols[$x]['size'])."</td>";
$p +=$cols[$x]['size'];
}
echo"<tr>{$record}</tr>";
$sent +=$blocksize;
}
echo"</tbody></table>";

Sure it could be cleaned up a bit but nice is not important, I need the 
data ...

Thanks,


On 5/25/21 2:34 PM, Bill Campbell via Filepro-list wrote:
> It's been decades since I had to do this.  I don't remember the
> details of the 40 character header other than the first character
> indicates whether the record is active or has been deleted.
>
> Beyond that, the key (and data) records have no delimiter
> separating the records, but are fixed length.  The key records
> are 40 + length of all fields so require reads of explicit
> length.  In python this might be:
>
> fh = open('pathtokeyfile', 'rb')
> n = 20 + reclength
> for rec in fh.read(n):
> 	hdr = rec[0:20]
> 	data = rec[20:]
> 	...
>
> On Tue, May 25, 2021, Jose Lerebours via Filepro-list wrote:
>> Can anyone tell me what is the BOR or EOR markers?
>>
>> I could save time if I know exactly what the first 40 or characters are or if
>> there is a delimiter/marker I can reference to split the segments.
>>
>> I put together sa simple script but it turns out that there is more to it
>> than I thought - Got to do some coding on some other stuff but I will
>> come back to this in a few ...  hope you guys have an answer for me by then!
>>
>> Thanks,
>>
>> -- 
>>
>> https://www.asisuites.com
>> https://www.helpsuites.com
>>
>> _______________________________________________
>> Filepro-list mailing list
>> Filepro-list at lists.celestial.com
>> Subscribe/Unsubscribe/Subscription Changes
>> http://mailman.celestial.com/mailman/listinfo/filepro-list
> Bill
-- 

https://www.asisuites.com
https://www.helpsuites.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.celestial.com/pipermail/filepro-list/attachments/20210525/d3930632/attachment.html>


More information about the Filepro-list mailing list