Commit ec7edf89 by mohammed.shibili

file uploading section added

parent 18007f3c
...@@ -3,9 +3,9 @@ import tkinter as tk ...@@ -3,9 +3,9 @@ import tkinter as tk
from tkinter import filedialog from tkinter import filedialog
# reading csv # reading csv
def csv_read(): def csv_read():
# section for file upload
try: try:
root = tk.Tk() root = tk.Tk()
root.withdraw() root.withdraw()
......
...@@ -27,17 +27,22 @@ async def get_element(): ...@@ -27,17 +27,22 @@ async def get_element():
async def get_minmax(): async def get_minmax():
datas = collection_name.find({}) datas = collection_name.find({})
dataframe = pd.DataFrame(list(datas)) dataframe = pd.DataFrame(list(datas))
# fetching min salary
min_salary = dataframe["salary"].min() min_salary = dataframe["salary"].min()
min_details = collection_name.find({"salary": min_salary}, {"_id": 0}) min_details = collection_name.find({"salary": min_salary}, {"_id": 0})
# fetching max salary
max_salary = dataframe["salary"].max() max_salary = dataframe["salary"].max()
max_details = collection_name.find({"salary": max_salary}, {"_id": 0}) max_details = collection_name.find({"salary": max_salary}, {"_id": 0})
# fetching average salary
avg_salary = dataframe["salary"].mean() avg_salary = dataframe["salary"].mean()
details = {"min": max_details, "max": min_details, "avg": avg_salary} details = {"min": max_details, "max": min_details, "avg": avg_salary}
# converting details to json
json_string = pd.io.json.dumps(details, orient="records", indent=4) json_string = pd.io.json.dumps(details, orient="records", indent=4)
with open('temp/details.json', 'w') as file: with open('temp/details.json', 'w') as file:
file.write(json_string) file.write(json_string)
df = pd.read_json("temp/details.json") df = pd.read_json("temp/details.json")
df.to_csv("temp/details.csv",index=False) # converting details to csv
df.to_csv("temp/details.csv", index=False)
return "data fetched" return "data fetched"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment