58131 041181603358--------------- 278 4------------------------------------------------------- --------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------V1.000021 6773 6760 7201 7266 7162 7393 7427 7574 7440 7303 7321 7440 6927 7233 7219 7504 7555 7458 7518 7833 7852 7652 7040 6672 6699 5926 5717 5738 60 73 6056 6325 6352 6965 7062 7094 7278 7465 7292 7324 7475 7562 7546 7314 7821 7869 7814 8178 8020 8300 7930 8608 8833 8643 8910 8927 8857 8976 8798 9535 90090022 9028 9818 9304 9042 8616 9044 9664 9966 970810022 962010491 9878 95581020610098100 0010564 99021020910279 8850 9246 9647 9310 8204 7860 8477 8313 8029 6600 6945 6503 6377 6212 5610 5732 5321 5302 5530 5973 5057 4293 4014 4826 5012 4955 4643 5218 5708 5861 6365 6756 6637 6534 8180 6732 6103 7344 7051
The above is the TXT format file data content, the file name "V5813101.012"
The format is: the first line, the description of the data file, as follows
Ordinal parameter number long remark
1. File Number 5 bytes
2. Year 5 bytes less than 5 bytes, front space
3. Month 5 bytes
4. Length 5 bytes.
5. Width 5 bytes
6. Alternate field 15 bytes Pre-fills each byte with a "-" (minus sign).
7. The height of 5 bytes high low when the front space.
8. Identification 5 bytes filled with "4"
9. Subsequent reserved bytes are populated with a "-" (minus sign) so that the parameter row is the same length as the subsequent data record line.
V1.00 4 bytes
11. Carriage return newline 2 bytes
Start with the second line
The minute data record line starts at line 2nd of the file, each hour is a record line, the length of each row is equal, and the record length is 60x5+6. The sorting order is: 2-bit "date", 2-bit "hour", 60-minute *5+2-bit "carriage return".
1 months for a file, there's Wood there's a very simple way to read the data and then write to the database.
A perfect match.
Reply to discussion (solution)
$FN = ' V5813101.012 '; $ar = File ($fn, File_ignore_new_lines | File_ignore_new_lines);//processing the first line $h = sscanf (Str_replace (", ' _ ', $ar [0]),"%5s%5s%5s%5s%5s%15s%5s%5s%249s%5s "); Array_ Walk ($h, function (& $v, $k, $t) {$v = Strtr ($v, $t);}, Array (' _ ' = ') ');p Rint_r ($h);//processing remaining lines for ($i =1; $i
Can only say that you are too cow!!
But there's one more question.
7th line Error
Parse error:syntax error, unexpected t_function in read.php on line 7
If the line is commented out, it is printed out.
$FN = ' V5813101.012 '; $ar = File ($fn, File_ignore_new_lines | File_ignore_new_lines);//processing the first line $h = sscanf (Str_replace (", ' _ ', $ar [0]),"%5s%5s%5s%5s%5s%15s%5s%5s%249s%5s "); Array_ Walk ($h, function (& $v, $k, $t) {$v = Strtr ($v, $t);}, Array (' _ ' = ') ');p Rint_r ($h);//processing remaining lines for ($i =1; $i
It's line 6th.
Can only say that you are too cow!!
But there's one more question.
7th line Error
Parse error:syntax error, unexpected t_function in read.php on line 7
If the line is commented out, it is printed out.
$FN = ' V5813101.012 '; $ar = File ($fn, File_ignore_new_lines | File_ignore_new_lines);//processing the first line $h = sscanf (Str_replace (", ' _ ', $ar [0]),"%5s%5s%5s%5s%5s%15s%5s%5s%249s%5s "); Array_ Walk ($h, function (& $v, $k, $t) {$v = Strtr ($v, $t);}, Array (' _ ' = ') ');p Rint_r ($h);//processing remaining lines for ($i =1; $i
you haven't used php5.3 yet?
You can write a callback function separately
array_walk ($h, ' foo ', Array (' _ ' = ') '); function foo (&am
p; $v, $k, $t) {$v = Strtr ($v, $t);}
The purpose of this callback is to change the space previously changed to "_" back to
Yes, it should be the version problem, thanks!
You haven't used the php5.3 yet?
You can write a callback function separately
array_walk ($h, ' foo ', Array (' _ ' = ') '); function foo (&am
p; $v, $k, $t) {$v = Strtr ($v, $t);}
The purpose of this callback is to change the space previously changed to "_" Back to
you haven't used php5.3 yet?
You can write a callback function separately
array_walk ($h, ' foo ', Array (' _ ' = ') '); function foo (&
$v, $k, $t) {$v = Strtr ($v, $t);}
The purpose of the
callback is to change the space previously changed to "_" Back to