Skip to content

Commit eb93d60

Browse files
Dean SoferDean Sofer
authored andcommitted
Using 19hz crawler
1 parent b586f98 commit eb93d60

5 files changed

Lines changed: 219 additions & 165 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
SPOTIFY_CLIENT_SECRET: ${{ secrets.SPOTIFY_CLIENT_SECRET }}
3434
run: |
3535
sed -i "s/__APIFY_TOKEN__/${APIFY_TOKEN}/g" map.js
36+
sed -i "s/__APIFY_TOKEN__/${APIFY_TOKEN}/g" map.js 19hz/map.js
3637
sed -i "s/__GOOGLE_TOKEN__/${GOOGLE_TOKEN}/g" index.html
3738
sed -i "s/__SPOTIFY_CLIENT_ID__/${SPOTIFY_CLIENT_ID}/g" 19hz/map.js
3839
sed -i "s/__SPOTIFY_CLIENT_SECRET__/${SPOTIFY_CLIENT_SECRET}/g" 19hz/map.js

19hz/extract-venues.js

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
const fs = require('fs');
2+
3+
const CSV_FILES = [
4+
https://19hz.info/events_BayArea.csv
5+
https://19hz.info/events_LosAngeles.csv
6+
https://19hz.info/events_Seattle.csv
7+
https://19hz.info/events_Atlanta.csv
8+
https://19hz.info/events_Miami.csv
9+
https://19hz.info/events_DC.csv
10+
https://19hz.info/events_Toronto.csv
11+
https://19hz.info/events_Iowa.csv
12+
https://19hz.info/events_Texas.csv
13+
https://19hz.info/events_PHL.csv
14+
https://19hz.info/events_Denver.csv
15+
https://19hz.info/events_CHI.csv
16+
https://19hz.info/events_Detroit.csv
17+
https://19hz.info/events_Massachusetts.csv
18+
https://19hz.info/events_LasVegas.csv
19+
https://19hz.info/events_Phoenix.csv
20+
https://19hz.info/events_ORE.csv
21+
https://19hz.info/events_BC.csv
22+
];
23+
24+
function parseCSV(csvText) {
25+
const rows = [];
26+
const lines = csvText.split('\n');
27+
28+
for (const line of lines) {
29+
if (!line.trim()) continue;
30+
31+
const row = [];
32+
let currentField = '';
33+
let inQuotes = false;
34+
35+
for (let i = 0; i < line.length; i++) {
36+
const char = line[i];
37+
38+
if (char === '"') {
39+
if (inQuotes && line[i + 1] === '"') {
40+
currentField += '"';
41+
i++;
42+
} else {
43+
inQuotes = !inQuotes;
44+
}
45+
} else if (char === ',' && !inQuotes) {
46+
row.push(currentField.trim());
47+
currentField = '';
48+
} else {
49+
currentField += char;
50+
}
51+
}
52+
53+
row.push(currentField.trim());
54+
rows.push(row);
55+
}
56+
57+
return rows;
58+
}
59+
60+
function extractVenuesFromCSV(filename) {
61+
console.log(`\nProcessing ${filename}...`);
62+
const csvText = fs.readFileSync(filename, 'utf8');
63+
const rows = parseCSV(csvText);
64+
65+
const venues = new Set();
66+
67+
rows.forEach((row, index) => {
68+
if (row.length >= 4) {
69+
const venueName = row[3];
70+
if (venueName && venueName.includes('(') && venueName.includes(')')) {
71+
venues.add(venueName);
72+
}
73+
}
74+
});
75+
76+
console.log(`Found ${venues.size} unique venues`);
77+
return Array.from(venues).sort();
78+
}
79+
80+
console.log('Extracting venues from CSV files...');
81+
82+
const allVenues = new Map();
83+
84+
CSV_FILES.forEach(file => {
85+
const venues = extractVenuesFromCSV(file);
86+
venues.forEach(venue => {
87+
const match = venue.match(/^(.+?)\s*\((.+)\)$/);
88+
if (match) {
89+
const name = match[1].trim();
90+
const address = match[2].trim();
91+
allVenues.set(venue, { name: venue, address: address });
92+
}
93+
});
94+
});
95+
96+
console.log(`\nTotal unique venues across all files: ${allVenues.size}`);
97+
console.log('\nWriting to new-venues.json...');
98+
99+
const venueArray = Array.from(allVenues.values());
100+
fs.writeFileSync('new-venues.json', JSON.stringify(venueArray, null, 2));
101+
102+
console.log(`Done! Wrote ${venueArray.length} venues to new-venues.json`);

0 commit comments

Comments
 (0)