From f582af7e19a6e4c1430f57243ed7e94479e90b07 Mon Sep 17 00:00:00 2001 From: Shivam Gutgutia Date: Mon, 2 Sep 2024 14:02:56 +0530 Subject: [PATCH] Added JSON file upload --- utils/createDf.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/createDf.py b/utils/createDf.py index 34e8d56..fa6d1b9 100644 --- a/utils/createDf.py +++ b/utils/createDf.py @@ -1,4 +1,4 @@ -from pandas import read_csv, read_excel +from pandas import read_csv, read_excel,read_json def createDf(requestFiles): if "file" not in requestFiles or not requestFiles["file"]: @@ -11,12 +11,14 @@ def createDf(requestFiles): df = read_excel(file,dtype=str) elif (file.filename.endswith(".ods")): df = read_excel(file,engine="odf",dtype=str) + elif file.filename.endswith(".json"): + df = read_json(file, dtype=str) else: return False,"Please upload valid file format" df = df.applymap(lambda x: x.strip() if isinstance(x,str) else "") df = df.loc[~(df == "").all(axis=1)] - + if not len(df): return False,"Empty file uploaded" return True,df