PHP File Processing

Assignment Description

Complete the PHP program named project3.php. This file program has a main function that prompts the user for an input file name and an output file name; there is a comment indicating where to start the implementation of your solution. The program should have the following general outline:

  1. Read the contents of the input file (the main function checks if the file exists, so you do not need to check that.)

  2. Transform the data into a different format.

  3. Write the transformed data to the output file.

There is an input file named animals.dat included in the handout directory. This file has four lines for; the lines of data will contain the following information, in this order:

The expected output file format is as follows:

Instructions

To start the assignment, login to your university Linux account and copy the assignment code to a location somewhere under your home directory. The assignment code is located at:

/export/home/public/schwesin/csc242/projects/project3-handout

You need to edit the project3.php file. Do not change the names of the file.

To submit your assignment, execute the following command from within your project3-handout directory:

    ~schwesin/bin/submit csc242 project3

Grading Criteria

Note: If the code has syntax errors or does not execute properly, you will receive a failing grade for this assignment. If the submission includes material that was not covered in class and the material is not properly cited, then you will receive a failing grade for this assignment.

Appendix

Expected contents of the output file for the given animals.dat file:

Animal,Class,Status,Total
African penguin,bird,EN,39
Western lowland gorilla,mammal,CR,33
Massi giraffe,mammal,VU,20
Scimitar-horned oryx,mammal,EW,20
Grants zebra,mammal,LC,20
Dart frog,amphibian,LC,19
Red kangaroo,mammal,LC,19
Black-capped lorikeet,bird,LC,17
Saddle-billed stork,bird,LC,13
Emu,bird,LC,12
African spurred tortoise,reptile,LC,9
Tammar wallaby,mammal,LC,9
Aardvark,mammal,LC,9
Gila monster,reptile,NT,8
Northern bald eagle,bird,LC,8
White rhino,mammal,NT,7
Blue-throated macaw,bird,EN,6
Tropical forest snake,reptile,VU,5
Loggerhead sea turtle,reptile,VU,4
Wyoming Toad,amphibian,EW,3
Chinese alligator,reptile,EN,2