{"id":801,"date":"2023-11-08T10:34:32","date_gmt":"2023-11-08T09:34:32","guid":{"rendered":"https:\/\/eventi-area2.invalsi.it\/?page_id=801"},"modified":"2023-12-15T10:25:38","modified_gmt":"2023-12-15T09:25:38","slug":"testpage","status":"publish","type":"page","link":"https:\/\/eventi-area2.invalsi.it\/en\/testpage\/","title":{"rendered":"testpage"},"content":{"rendered":"<!-- CSS -->\n<style type=\"text\/css\">\n    table th, table td{\n    padding: 5px;\n}\n<\/style>\n\n<div>\n\n    <div>\n         <input type=\"file\" name=\"file\" id=\"file\" accept=\".csv\" > <br><br>\n         <input type=\"button\" id=\"btnsubmit\" value=\"Submit\" onclick=\"readCSVFile();\" >\n    <\/div>\n\n    <br><br>\n    <!-- List CSV file data -->\n    <table id=\"tblcsvdata\" border=\"1\" style=\"border-collapse: collapse;\">\n         <thead>\n              <tr>\n                  <th>S.no<\/th>\n                  <th>Username<\/th>\n                  <th>Name<\/th>\n                  <th>Email<\/th>\n              <\/tr>\n         <\/thead>\n         <tbody>\n\n         <\/tbody>\n\n    <\/table>\n<\/div>\n<script>\nfunction readCSVFile(){\n     var files = document.querySelector('#file').files;\n\n     if(files.length > 0 ){\n\n          \/\/ Selected file\n          var file = files[0];\n\n          \/\/ FileReader Object\n          var reader = new FileReader();\n\n          \/\/ Read file as string \n          reader.readAsText(file);\n\n          \/\/ Load event\n          reader.onload = function(event) {\n\n               \/\/ Read file data\n               var csvdata = event.target.result;\n\n               \/\/ Split by line break to gets rows Array\n               var rowData = csvdata.split('\\n');\n\n               \/\/ <table > <tbody>\n               var tbodyEl = document.getElementById('tblcsvdata').getElementsByTagName('tbody')[0];\n               tbodyEl.innerHTML = \"\";\n\n               \/\/ Loop on the row Array (change row=0 if you also want to read 1st row)\n               for (var row = 1; row < rowData.length; row++) {\n\n                     \/\/ Insert a row at the end of table\n                     var newRow = tbodyEl.insertRow();\n\n                     \/\/ Split by comma (,) to get column Array\n                     rowColData = rowData[row].split(';');\n\n                     \/\/ Loop on the row column Array\n                     for (var col = 0; col < rowColData.length; col++) {\n\n                          \/\/ Insert a cell at the end of the row\n                          var newCell = newRow.insertCell();\n                          newCell.innerHTML = rowColData[col];\n\n                     }\n\n               }\n          };\n\n     }else{\n          alert(\"Please select a file.\");\n     }\n\n}\n<\/script>","protected":false},"excerpt":{"rendered":"<p>S.no Username Name Email<\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/pages\/801"}],"collection":[{"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/comments?post=801"}],"version-history":[{"count":82,"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/pages\/801\/revisions"}],"predecessor-version":[{"id":1070,"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/pages\/801\/revisions\/1070"}],"wp:attachment":[{"href":"https:\/\/eventi-area2.invalsi.it\/en\/wp-json\/wp\/v2\/media?parent=801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}