(Please help) php, perl, and other script software to split one file into multiple TXT files

Source: Internet
Author: User
(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.