@@ -91,9 +91,9 @@ def get_csv_file(filename: str):
9191 extension = parts [- 1 ] if parts else ""
9292 extension = extension .lstrip ("." )
9393
94- if not extension or extension not in ["csv" , "xlsx" ]:
94+ if not extension or extension not in ["csv" , "xlsx" , "json" , "jsonl" ]:
9595 frappe .throw (
96- f"Only CSV and XLSX files are supported. Detected extension: '{ extension } ' from filename: '{ file_name } '"
96+ f"Only CSV, XLSX, JSON, and JSONL files are supported. Detected extension: '{ extension } ' from filename: '{ file_name } '"
9797 )
9898 return file , extension
9999
@@ -128,6 +128,8 @@ def get_file_data(filename: str):
128128 try :
129129 if ext in ["xlsx" ]:
130130 table = db .read_xlsx (file_path )
131+ elif ext in ["json" , "jsonl" ]:
132+ table = db .read_json (file_path )
131133 else :
132134 table = db .read_csv (file_path , table_name = file_name )
133135
@@ -162,6 +164,8 @@ def import_csv_data(filename: str, tablename: str = ""):
162164 try :
163165 if ext in ["xlsx" ]:
164166 table = db .read_xlsx (file_path )
167+ elif ext in ["json" , "jsonl" ]:
168+ table = db .read_json (file_path )
165169 else :
166170 table = db .read_csv (file_path , table_name = table_name )
167171 db .create_table (table_name , table , overwrite = True )
@@ -171,6 +175,10 @@ def import_csv_data(filename: str, tablename: str = ""):
171175 frappe .throw (
172176 "Failed to read Excel data from uploaded file. Please ensure the file is a valid Excel format and try again."
173177 )
178+ elif ext in ["json" , "jsonl" ]:
179+ frappe .throw (
180+ "Failed to read JSON data from uploaded file. Please ensure the file is a valid JSON or JSONL format and try again."
181+ )
174182 else :
175183 frappe .throw ("Failed to read CSV data from uploaded file. Please try again." )
176184 finally :
0 commit comments