(ask for help) Php,perl and other scripting software to split a file for multiple TXT files related issues

Source: Internet
Author: User
(ask for help) Php,perl and other scripting software to split a file for multiple TXT file issues.
Php,perl such as scripting software to split a file for multiple TXT file issues.
The contents of the file are as follows:
Ip,moindex,classname,fdn,latitude,longitude,matchversion,name,neid,netype,neversion,reallatitude,reallongitude , VendorName,
10.133.10.21,18,bsc6000ne,.3221229568.3221233664.3221291023,281.0,524.0,imanagerm2000_bsc6000_match_chs_ V200r008c12spc025,bj-hw-bsc03,18,bsc6000,bsc6000v900r008c12,0dn,0de,huawei,


Bscindex,grpindex,moindex,classname,fdn,name,neid,
0,0,18_0_0,BSC6000BCGRP,.3221229568.3221233664.3221291023.3221581834,BC Collection, 18,


Moindex,classname,fdn,name,neid,
18,bsc6000equipment,.3221229568.3221233664.3221291023.3221393419,bsc6000equipment,18,


Moindex,classname,fdn,name,neid,
18,bsc6000function,.3221229568.3221233664.3221291023.3221397515,bsc6000function,18,


Bscindex,grpindex,moindex,classname,fdn,name,neid,
0,0,18_0_0,BSC6000HDLCLINKGRP,.3221229568.3221233664.3221291023.3221721098,HDLC Link Collection, 18,

Description: This txt has a lot of similar columns, the rule is that every two lines have two rows of data, the first row is the field name, the second row is the data.

Requirements:
1 read in the file. Then search each field row, find the location of the classname in the row, and then follow this location, record the name of the data row for each classname field, usually called BSC6000 .... of this.
2 then follow this name to create a text file that writes the relevant word marked field and data lines to the new file.
The 3 write format remains the same as before, except that two lines of empty lines are not required to pull the middle.

I belong to the vegetable rookie. Tried several ways. It doesn't seem to be successful. Very depressed, so ask you heroes. What are the tricks to solve this problem?




------Solution--------------------
1, a line of reading, according to the rules of a line of writing
2, if you understand the regular. You can consider using regular, 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.