PHP reads txt data by line length and stores it in MySQL
58131 041181603358--------------- 278 4------------------------------------------------------- --------------------------------------------------V1.00
0021 6773 6760 7201 7266 7162 7393 7427 7574 7440 7303 7321 7440 6927 7233 7219 7504 7555 7458 7518 7833 7852 7652 7040 66 72 6699 5926 5717 5738 6073 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 9009
0022 9028 9818 9304 9042 8616 9044 9664 9966 970810022 962010491 9878 955810206100981000010564 99021020910279 8850 9246 96 47 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.
10.v1.004 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.
Share to:
------Solution--------------------
$FN = ' V5813101.012 ';
------Solution--------------------
File_ignore_new_lines);
Handling the first line