forked from gaureshpai/cert-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (47 loc) · 1.78 KB
/
index.js
File metadata and controls
57 lines (47 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// First, let's fetch and analyze the CSV data
const csvUrl = './index.csv';
async function fetchAndAnalyzeData() {
try {
const response = await fetch(csvUrl);
const csvText = await response.text();
console.log('CSV Data Preview:');
console.log('================');
// Split into lines and show first 10 rows
const lines = csvText.split('\n');
lines.slice(0, 10).forEach((line, index) => {
console.log(`Row ${index}: ${line}`);
});
console.log(`\nTotal rows: ${lines.length}`);
// Parse CSV to understand the data structure
const rows = lines.slice(1).filter(line => line.trim()); // Skip header and empty lines
const participants = rows.map(row => {
const columns = row.split(',').map(col => col.trim().replace(/"/g, ''));
return {
id: columns[0],
name: columns[1],
college: columns[2],
events: columns[3]
};
});
console.log('\nSample parsed data:');
console.log('==================');
participants.slice(0, 5).forEach(p => {
console.log(`ID: ${p.id}, Name: ${p.name}, College: ${p.college}, Events: ${p.events}`);
});
// Analyze event patterns
const eventPatterns = new Set();
participants.forEach(p => {
if (p.events) {
eventPatterns.add(p.events);
}
});
console.log('\nUnique event patterns:');
console.log('=====================');
Array.from(eventPatterns).slice(0, 10).forEach(pattern => {
console.log(pattern);
});
} catch (error) {
console.error('Error fetching data:', error);
}
}
fetchAndAnalyzeData();