(Please help) php, perl, and other script software split one file into multiple TXT files. Php, perl, and other script software split a file into multiple TXT files. The file content is as follows: IP, MOIndex, className, fdn, latitude, longpolling, matchVersion, name, neID, neType, neVersion, realLatitude, realLo (for help) php, perl and other script software split a file into multiple TXT files.
Php, perl, and other script software split a file into multiple TXT files.
The file content is as follows:
IP, MOIndex, className, fdn, latitude, longpolling, matchVersion, name, neID, neType, neVersion, realLatitude, reallongpolling, vendorName,
10.133.10.21, 18, BSC6000NE,. 3221229568.3221231044.3221291023, 281.0, 524.0, large, BJ-HW-BSC03, 18, BSC6000, BSC6000V900R008C12, 0DN, 0DE, Huawei,
BSCIndex, GrpIndex, MOIndex, className, fdn, name, neID,
0, 0, 18_0_0, BSC6000BCGrp,. 3221229568.3221231044.3221291023.3221581834, BC set, 18,
MOIndex, className, fdn, name, neID,
18, BSC6000Equipment,. 3221229568.3221231044.3221291023.3231693419, Bsc6000Equipment, 18,
MOIndex, className, fdn, name, neID,
18, BSC6000Function,. 3221229568.3221231044.3221291023.3231697515, Bsc6000Function, 18,
BSCIndex, GrpIndex, MOIndex, className, fdn, name, neID,
0, 0, 18_0_0, BSC6000HDLCLinkGrp,. 3221229568.3221231044.3221291023.3221721098, HDLC link set, 18,
Note: There are many similar rows and columns in this txt file. The rule is that there are two rows of data every two rows. the first row is the field name, and the second row is the data.
Requirements:
1. read the file. Search for each field row, locate the className location in the row, and record the name of the data row corresponding to each className field, which is generally called bsc6000.
2. create a text file based on the name and write the related field row and data row into the new file.
3. the write format remains the same, but the two lines in the middle are not required to be pulled.
I belong to Cainiao. I tried several methods. It seems that none of them are successful. Very depressed, so I would like to ask you. How can I solve this problem?
------ Solution --------------------
1. read one row and write one row according to regular
2. if you know about regular expressions. You can use regular expressions and write