Posts Tagged ‘programming’

Python: Orders Manager P2

August 22, 2019 Leave a comment

Orders Managment System
Subject: Main Menu and creation of the data file – P2

First thing we will talk about the menu, in this post we will cover the Main Menu and the user choice. Also we will add some validation.

Main Menu: Here is a list of what we will have in the main menu with some descriptions for each choice.
Load File: We will name the file as “orders_data.csv” so once we start the application the system will check if the file exist or not, if Yes then the application will load it automatically as DataFrame (df) if not thats mean you are running the app for the first time, so we will go through file creating process.

Show Data: In this option we will have another sub menu page having:
1. Show all data.
2. Show sample data.
3. Show last 5 records.

Sort: Here we will have sorting as columns that we have, the user will select a column.

Search: We can here search for an order by Date, Price, Quantity or details, also we will do groping for the data.
Missing Data: To show us how many missing data we have so we can fill them.
Add New Order: To add new order to the system.
Edit a Record: To Edit/change a record.
Delete a Record: To delete a record from the DataFrame.
Save: To save what ever you do to the DataFrame.

The Main Menu

def the_menu ():

print(‘\n ::—–{ The menu }—-::’)

print(‘1. Create New csv File’)

print(‘2. Show Data’)

print(‘3. Sort.’)

print(‘4. Search.’)

print(‘5. Missing Data’)

print(‘6. Add New Record.’)

print(‘7. Edit a record.’)

print(‘8. Delete a Record.’)

print(’9. Save the File.’)

return input(‘\n Select from the menu (”q” to quit): ‘)

Main while loop: In the application body we will use a while loop to control the user input and run the function he select. Unlike what we did In the zoo managment system, we will add a validation on the user input as:

1. If the user enter any thing else than numbers (1 to 9) or ([q – Q] for quit) nothing will happen.
2. If the user select (q to quit) then we will ask if he want to save before Exit.

Here is the code …

Main while loop
# calling the menu
user_enter = the_menu()

Validation: If the user enter any thing else than numbers
or (q for quit) nothing will happen.
while user_enter !=’q’ or ‘Q’ :

if user_enter in [‘q’,’Q’] :

print(‘\n You select to Exit the application.’)

save_it = input(‘\n Do your want to save your work/changes [y or n] ? ‘)

if save_it in [‘y’,’Y’]:

save_the_df (df)


elif user_enter not in [‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’] :

user_enter = the_menu()



user_enter = the_menu()

Here is a screen shot for the code..

In this post we cover the Main Menu and the main while loop we need to call the functions, in the coming post we will create the data file and Adding new record.

Follow me on Twitter..


Python: Orders Manager P1

August 20, 2019 Leave a comment

Orders Managment System
Subject: Outlines – P1

In last several posts we develop a Zoo Managment System [Click to Read]. We try to use our skills in python and pandas to work with DataFrame and developing easy app that reading and writeing a csv file. We will use the same principle and re-use most of it’s functions to write our new coming system.

The Story: I don’t think that there is any person using the web without using at least one of the online shopping sites, personally; I am using three sites. In coming posts we will work on Orders Managment System (OMS) to track our orders.

General Enhancement In the Zoo application we did not use any validation or try … Exceptions blocks, but this time we will use a range of validations over the user input starting from the menu until asking if the user want to save shange before he Quit. Using validations will make the code (or make it looks like) complicated, so I will use lots of comments to describe some codes.

Validation Example ..
In our Date entry, we will inform the user that we want the date as DD-MM-YYYY , then if the user enter any thing not logic (not a date) or say he enter “3/8-2019” our validation will convert that to “03-08-2019”.

OMS Outline: In this application our goal is to practices on data validation so we will develop a system to store our orders data and apply the validation on it, I will use aliexpress orders information to build the csv file. As far as i know, aliexpress site is not providing any tool to export a file that contain your orders detail so we will do this just to keep a history records of our orders.

File Structuer: The file will have 8 columns here is a short description of each column:
order_no: A serial number that will increment automatically, we will consider this to be a primary key of the table.
order_id: This is the order id generated by aliexpress site, we will enter it as it is.
order_date: To hold the orders date, the date will be in DD-MM-YYYY format.
order_detail: Short description of the order, even you write it in your words or copy paste it from your order page.
item_price: The price in US$
ship_price: Shipment amount in US$
quantity: The Quantity of the items.
item_url: The URL of the item page.

Coming Post We will start from next post to write the main menu, and the first function to create a csv file and insert the first row.

Follow me on Twitter..