From 13f8aa51b9c834cc5852529a61c814c500052b88 Mon Sep 17 00:00:00 2001 From: Kevin Novak Date: Tue, 26 Nov 2019 21:30:50 -0500 Subject: [PATCH] Fix for large CSV files --- public/scripts/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/scripts/index.js b/public/scripts/index.js index 192ffcf..575f230 100644 --- a/public/scripts/index.js +++ b/public/scripts/index.js @@ -151,10 +151,12 @@ async function retrieveSteamSearchTable() { textArea.readOnly = true; textArea.innerHTML = text; - let csv = json2csv.parse(cache.searchData); + let csvString = "\ufeff" + json2csv.parse(cache.searchData); + let csvData = new Blob([csvString], { encoding: 'UTF-8', type: 'text/csv;charset=UTF-8' }); + let csvUrl = URL.createObjectURL(csvData); let downloadLink = document.createElement('a'); - downloadLink.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv); + downloadLink.href = csvUrl; downloadLink.target = '_blank'; downloadLink.innerHTML = 'Download Raw Data as CSV'; downloadLink.download = `steam-data-${getFormattedTime()}.csv`;