Skip to content

Instantly share code, notes, and snippets.

@plasticmind
Created March 27, 2024 13:35
Show Gist options
  • Save plasticmind/5b840cc07673dddfb219021315a5c3e9 to your computer and use it in GitHub Desktop.
Save plasticmind/5b840cc07673dddfb219021315a5c3e9 to your computer and use it in GitHub Desktop.
Output UXPin Projects to CSV
// 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