/ConvoyShippingCompany

Project about working with different files(xlsx, csv, json, xml) and converting them to s3db in Python.

Primary LanguagePython

ConvoyShippingCompany

The final version: final stage/convoy.py

Objectives

1. Prompt the user to give a name for the input file (complete with the .xlsx, .csv, [CHECKED].csv or .s3db extension). For the prompt message, use Input file name followed by a newline.
2. If your file is .xlsx or .csv, or it ends with %...%[CHECKED].csv, perform:
a.If your file is .xlsx, convert it to .csv.
b.If your file is .csv correct the data right in the file.
c.Every cell of the output file, except headers, should contain only one integer number.
d.Count the number of the cells corrected by your script.
e.Write the corrected data to a CSV file, add the [CHECKED] suffix to your file. For example: %file_name%[CHECKED].csv.
f.Your program should output the following message for the converted CSV file: X cells were corrected or 1 cell was corrected, where X is the number of corrected       cells. Include the output file name.
For example: 4 cells were corrected in %file_name%[CHECKED].csv.
3. If the file ends with %...%[CHECKED].csv, create an SQLite3 database with the CSV file name, change its extension to .s3db. Remove the [CHECKED] suffix. For example, %file_name%[CHECKED].csv should be changed to %file_name%.s3db.
4. Use "convoy" as the name for your database table and headers from the CSV file as the names of the table columns.
5. The vehicle_id column should have the INTEGER type; make sure it's PRIMARY KEY, other columns should have the INTEGER type with NOT NULL attributes.
6. Insert the entries from your %...%[CHECKED].csv file. Count the number of entries inserted into the database. Your program should output the following message: X records were inserted or 1 record was inserted, where X is a number of inserted records and the output file name. For example: 4 records were inserted into %file_name%.s3db.
7. Add the score column to .s3db files. Populate the column with the scoring points, according to the algorithm described above. The score column should be added during the conversion from %...%[CHECKED].csv to .s3db.
8. Generate JSON and XML files according to the scoring points. All entries with a score of greater than 3 should be exported to the JSON file, others to the XML file. The score column should not be exported to JSON and XML files.
9. Count the number of entries imported to JSON and XML files. Your program should output the following message: X vehicles were saved or 1 vehicle was saved, where X is the number of inserted entries. The program should include the output file name.
For example: 9 vehicles were saved into %file_name%.json 0 vehicles were saved into %file_name%.xml

Examples

12

XLSX file data_final_xlsx.xlsx

13

CSV file data_final_xlsx[CHECKED].csv

14

Scoring function

11

S3BD file data_final_xlsx.s3bd

15

JSON file data_final_xlsx.json

15

XML file data_final_xlsx.xml

16