mercredi 1 juillet 2015

Compare two files in C, one file format is fixed and input files must have same format but different contents

<School>
      </SchoolName>latha2  //skip, but keep
</School>

<Student>
   <Team>power  //skip,but keep
   <StudentNo>1 //skip
       <Sport>
            <StartDate>16122016</StartDate> //*skip(May or maynot contained)
            <SportType>All 
            <ExpiryDate>16122020</EndDate> //*skip (May or maynot contained)
       </Sport>

 <Personal> 
   <phone>50855466 //skip,but keep
   <rollno>6 //skip,but keep
 </Personal>
 <hobby>  //skip
</Student>

Note: There are 4 <Student> tags.

  • Assume that File1 is fixed and File2 is input-file. In File 1,one school with 4 students. In File 2,there are many schools but have to check with File-1 format repeatedly according to the number of schools it has. Above is an example of File1.

"Scenario" - There are 4 package of "Student" tags in one school. In each tags, the value of "Team" are repeated.

"Questions with restrictions"

  1. From File 1,"Sport" Tag, "StartDate" and "ExpiryDate" are defined but they may not be contained in every "School" from File2.
    • If they are defined, how to verify that they should be at the correct line?.
    • How to verify that format is right even they are not defined in some schools of File2?
  2. Some lines are skipped when 2 files are compared but some lines need to be collected form File2 to write a new txt even they are skipped. From File2, "SchoolName", "Team","phone" and "roll no" are retrieved and write txt altogether line by line. ****Important, retrieve "Team" once from one "School". Because it is repeated 4 times in four "Student" from same "School".
    • How to retrieve only SchoolName,Team,Phone,RollNo among the skipped lines?
    • How to retrieve only Team in writing new textfile even it is duplicated in students under one school?

Two things to be done. 1. Match File Format 2.New Text with specific values

"Example of new text"

 latha2   // SchoolName    
 power    // Team
 5035546  // phone  - student1
 6        // rollno - student1
 5089973  // phone  - student2
 5        // rollno - student2
 5402734  // phone  - student3
 1        // rollno - student3
 8540345  // phone  - student4
 2        // rollno - student4

Aucun commentaire:

Enregistrer un commentaire