Hi,
I have a fixed length flat file - each 'record' in the file has a length of 80. I need to read this file and then extract data from various positions within each record and then write it to another file.
For example: the input file has data like this:
74807932020002100010020808 0000002355 26240992 74807932020002100011020808 0000090000 262409
74807932020002100011020808 0000090000 26240993 74807932020002100012020808 0000078654 262409
74807932020002100012020808 0000078654 26240994 74807932020002100013020808 0000055023 262409
I need to extract account number which is in pos 3 - 12 and then I need amount which is in pos 30 - 39 and so on...How do I do that?
Please help !
I have started writing code to read the file:
$filename = "input.txt" ;
$dataFile = fopen( $filename, "r" ) ;
if ( $dataFile )
{
while (!feof($dataFile))
{
$buffer = fgets($dataFile, 4096);
echo $buffer;
}
fclose($dataFile);
}
else
{
die( "fopen failed for $filename" ) ;
}
but after this, I am kinda stuck on how I can read each 'record' at a time and extract data from each 'record'?
Thanks.
I have a fixed length flat file - each 'record' in the file has a length of 80. I need to read this file and then extract data from various positions within each record and then write it to another file.
For example: the input file has data like this:
74807932020002100010020808 0000002355 26240992 74807932020002100011020808 0000090000 262409
74807932020002100011020808 0000090000 26240993 74807932020002100012020808 0000078654 262409
74807932020002100012020808 0000078654 26240994 74807932020002100013020808 0000055023 262409
I need to extract account number which is in pos 3 - 12 and then I need amount which is in pos 30 - 39 and so on...How do I do that?
Please help !
I have started writing code to read the file:
$filename = "input.txt" ;
$dataFile = fopen( $filename, "r" ) ;
if ( $dataFile )
{
while (!feof($dataFile))
{
$buffer = fgets($dataFile, 4096);
echo $buffer;
}
fclose($dataFile);
}
else
{
die( "fopen failed for $filename" ) ;
}
but after this, I am kinda stuck on how I can read each 'record' at a time and extract data from each 'record'?
Thanks.