Created
March 27, 2024 13:35
-
-
Save plasticmind/5b840cc07673dddfb219021315a5c3e9 to your computer and use it in GitHub Desktop.
Output UXPin Projects to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy/paste this into your browser's console after the UXPin Dashboard has fully loaded | |
function arrayToCSV(data) { | |
const csvRows = []; | |
// Get the headers | |
const headers = Object.keys(data[0]); | |
csvRows.push(headers.join(',')); | |
// Loop over the rows and push to csvRows | |
for (const row of data) { | |
const values = headers.map(header => { | |
const escaped = ('' + row[header]).replace(/"/g, '\\"'); | |
return `"${escaped}"`; | |
}); | |
csvRows.push(values.join(',')); | |
} | |
return csvRows.join('\n'); | |
} | |
function downloadCSV(csvString, filename) { | |
const blob = new Blob([csvString], { type: 'text/csv;charset=utf-8;' }); | |
const link = document.createElement('a'); | |
link.href = URL.createObjectURL(blob); | |
link.setAttribute('download', filename); | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); | |
} | |
// Place this at the end of your data processing | |
setTimeout(() => { | |
const data = scrapeCurrentPageData(); | |
const csvData = arrayToCSV(data); | |
downloadCSV(csvData, 'project_data.csv'); | |
}, 5000); // Adjust the timeout as needed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment