diff --git a/frontend/src/Editor/Components/FilePicker.jsx b/frontend/src/Editor/Components/FilePicker.jsx index 5706e2f62b..c99807c038 100644 --- a/frontend/src/Editor/Components/FilePicker.jsx +++ b/frontend/src/Editor/Components/FilePicker.jsx @@ -386,25 +386,18 @@ FilePicker.AcceptedFiles = ({ children, width, height }) => { }; const processCSV = (str, delimiter = ',') => { - const headers = str.slice(0, str.indexOf('\n')).split(delimiter); - const rows = str.slice(str.indexOf('\n') + 1).split('\n'); - try { - const newArray = rows.map((row) => { - const values = row.split(delimiter); - const eachObject = headers.reduce((obj, header, i) => { - obj[header] = values[i]; - return obj; - }, {}); - return eachObject; - }); - - return newArray; + const wb = XLSX.read(str, { type: 'string' }); + const wsname = wb.SheetNames[0]; + const ws = wb.Sheets[wsname]; + const data = XLSX.utils.sheet_to_json(ws, { delimiter, defval: '' }); + return data; } catch (error) { console.log(error); handleErrors(error); } }; + const processXls = (str) => { try { const wb = XLSX.read(str, { type: 'base64' }); diff --git a/frontend/src/Editor/LeftSidebar/SidebarInspector.jsx b/frontend/src/Editor/LeftSidebar/SidebarInspector.jsx index 6d1adddef7..3c079e69d7 100644 --- a/frontend/src/Editor/LeftSidebar/SidebarInspector.jsx +++ b/frontend/src/Editor/LeftSidebar/SidebarInspector.jsx @@ -122,7 +122,7 @@ export const LeftSidebarInspector = ({ }; const copyToClipboard = (data) => { - const stringified = JSON.stringify(data, null, 2); + const stringified = JSON.stringify(data, null, 2).replace(/\\/g, ''); navigator.clipboard.writeText(stringified); return toast.success('Copied to the clipboard', { position: 'top-center' }); };