Commit ec7edf89 by mohammed.shibili

file uploading section added

parent 18007f3c
......@@ -3,9 +3,9 @@ import tkinter as tk
from tkinter import filedialog
# reading csv
def csv_read():
# section for file upload
try:
root = tk.Tk()
root.withdraw()
......
......@@ -27,17 +27,22 @@ async def get_element():
async def get_minmax():
datas = collection_name.find({})
dataframe = pd.DataFrame(list(datas))
# fetching min salary
min_salary = dataframe["salary"].min()
min_details = collection_name.find({"salary": min_salary}, {"_id": 0})
# fetching max salary
max_salary = dataframe["salary"].max()
max_details = collection_name.find({"salary": max_salary}, {"_id": 0})
# fetching average salary
avg_salary = dataframe["salary"].mean()
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)
with open('temp/details.json', 'w') as file:
file.write(json_string)
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"
......
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