122k views
0 votes
"NOTE: write an algorithm, not a code" You are given a file called "std" and composed of "Number, Name, Address" fields. (You can define the type of fields by yourself) Write an algorithm that makes "insert, delete, update and retrieve", processes on the records in the file. "Number" field is the key of each record. Here is the template of report: Steps Actions 1 Name of the report and date 2 Author of report 3. Literature review 4. Your contribution 5 Explanation algorithm and sub algorithms 6 Summary 7. Future advice 8. References

User EddieBytes
by
5.2k points

1 Answer

1 vote

Answer:

1. get the absolute path to the file

2. load the file as a table (dataframe in python)

3. to insert a row;

  • create a dataframe of the same field type
  • concatenate the new dataframe horizontally with the same dataframe

4. to delete a row, select and drop the row where the 'Number' field matches a value.

5. to update the values in row, use the number field as a key to replace the existing values.

6. print of save to a variable the rows where the number field matches a given value.

Step-by-step explanation:

Follow the report template to create a report for the algorithm.

The algorithm gets the absolute path to the file and loads the file as a tabular file from there the data can be queried without accessing the main file. The insert algorithm creates a new dataframe and appends it to the main dataframe.

The delete, update and retrieve all use the same subalgorithm, getting the rows with the number field as the key value.

User Vivekanand P V
by
6.0k points