-
Notifications
You must be signed in to change notification settings - Fork 0
52: Email send script #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
isabellalam12
wants to merge
4
commits into
main
Choose a base branch
from
52
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+157
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
daa11e5
52: Wrote code to parse the users.csv
isabellalam12 c55af98
52: added function to split lines and handle commas within quotation
isabellalam12 5db0332
52: finished csv parse code for pairings
isabellalam12 6d7d8d3
52: fixed logic error in pair object and map syntax
isabellalam12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| import fs from "fs"; | ||
|
|
||
| //Configuration Constants | ||
| const SENDER_NAME = "Patina Network" | ||
| const SENDER_EMAIL = "bella.patinanetwork@gmail.com" | ||
| const APP_PASSWORD = "" | ||
| const USERS_FILE = "js/src/app/user/admin/emails/users-test.csv" | ||
| const PAIRINGS_FILE = "js/src/app/user/admin/emails/pairings-test.csv" | ||
|
|
||
| //classes | ||
| class User { | ||
| constructor(name, intro, linkedin, industry, preferences, topics, anything) { | ||
| this.name = name; | ||
| this.intro = intro; | ||
| this.linkedin = linkedin; | ||
| this.industry = industry; | ||
| this.preferences = preferences; | ||
| this.topics = topics; | ||
| this.anything = anything; | ||
| } | ||
| } | ||
|
|
||
| class Pair{ | ||
| constructor(fullNameA, fullNameB, emailA, emailB) { | ||
| this.fullNameA = fullNameA; | ||
| this.fullNameB = fullNameB; | ||
| this.emailA = emailA; | ||
| this.emailB = emailB; | ||
| } | ||
| } | ||
|
|
||
| function validateCSV(csv) { | ||
| const requiredHeaders = ['Timestamp','Name','Email','Intro','LinkedIn','Industry','Preferences','Topics','Anything']; | ||
| const headers = csv[0]; | ||
| return requiredHeaders.every(header => headers.includes(header)); //returns true if all requiredheaders are present, false otherwise | ||
| } | ||
|
|
||
| function splitCSVLine(line){ //split lines w/ commas as deliminators (manually implmented to handle commas within quotes) | ||
| const result = []; | ||
| let current = ""; | ||
| let inQuotes = false; | ||
|
|
||
| for (let char of line) { | ||
| if (char === '"') { | ||
| inQuotes = !inQuotes; // Toggle the inQuotes flag | ||
| } | ||
| else if (char === ',' && !inQuotes) { | ||
| result.push(current.trim()); | ||
| current = ""; | ||
| } | ||
| else { | ||
| current += char; | ||
| } | ||
| } | ||
| result.push(current.trim()); // Add the last field | ||
| return result; | ||
| } | ||
|
|
||
| function parseUsers(csv){ | ||
| /* | ||
| Parse Users.csv and return a map from email addresses to User objects. | ||
|
|
||
| Args: | ||
| filename: Path to the Users.csv file | ||
|
|
||
| Returns: | ||
| Dictionary mapping email addresses (lowercase) to User objects | ||
| */ | ||
| const users = new Map(); | ||
| try{ | ||
| const data = fs.readFileSync(csv, "utf-8"); | ||
|
|
||
| const lines = data.split("\n").map(line => line.trim()).filter(line => line.length > 0); | ||
| const csvArray = lines.map(line => splitCSVLine(line, 9)); | ||
|
|
||
| if (!validateCSV(csvArray)) { | ||
| throw new Error("Invalid CSV: missing required headers."); | ||
| } | ||
| const headerIndex = csvArray[0].reduce((acc, header, index) => { | ||
| acc[header] = index; | ||
| return acc; | ||
| }, {}); | ||
|
|
||
| const usersMap = new Map(); | ||
|
|
||
| for (let i = 1; i < csvArray.length; i++) { | ||
| const row = csvArray[i]; | ||
| const email = row[headerIndex['Email']].toLowerCase(); | ||
|
|
||
| const user = new User( | ||
| row[headerIndex['Name']], | ||
| row[headerIndex['Intro']], | ||
| row[headerIndex['LinkedIn']], | ||
| row[headerIndex['Industry']], | ||
| row[headerIndex['Preferences']], | ||
| row[headerIndex['Topics']], | ||
| row[headerIndex['Anything']] | ||
| ); | ||
| usersMap.set(email, user); | ||
| } | ||
| //console.log(usersMap); //testing | ||
| return usersMap; | ||
|
|
||
|
|
||
| } | ||
| catch (err){ | ||
| console.error(`Error parsing CSV: ${err}`); | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| function parsePairs(csv){ | ||
| /* | ||
| Parse Pairings-Apr26.csv and return a list of Pairing objects. | ||
|
|
||
| Args: | ||
| filename: Path to the pairings CSV file | ||
|
|
||
| Returns: | ||
| List of Pairing objects | ||
| */ | ||
| const pairings = []; | ||
| try{ | ||
| const data = fs.readFileSync(csv, "utf-8"); | ||
| const lines = data.split("\n").map(line => line.trim()).filter(line => line.length > 0); | ||
| const csvArray = lines.map(line => line.split(",").map(cell => cell.trim())); | ||
| for (let i = 0; i < csvArray.length; i++) { | ||
| const row = csvArray[i]; | ||
| if (row == undefined || row.length < 4) { | ||
| console.log(`Warning: Skipping malformed row: ${row}`); | ||
| continue; | ||
| } | ||
| const pair = new Pair( | ||
| row[0], //fullNameA | ||
| row[2], //fullNameB | ||
| row[1], //emailA | ||
| row[3] //emailB | ||
| ); | ||
|
|
||
| pairings.push(pair); | ||
|
|
||
| } | ||
| }catch (err){ | ||
| console.error(`Error parsing CSV: ${err}`); | ||
| } | ||
| console.log(pairings); //testing | ||
| return pairings; | ||
| } | ||
|
|
||
| parseUsers(USERS_FILE); | ||
| parsePairs(PAIRINGS_FILE); | ||
|
|
||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Tahmid Ahmed,tahmid@tahmid.io,Andrew Yu,hunter.vyb5t@gmail.com |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Timestamp,Name,Email,Intro,LinkedIn,Industry,Preferences,Topics,Anything,,, | ||
| 4/14/2026 21:30:13,Tahmid Ahmed,tahmid@tahmid.io,"Tahmid is a senior at Hunter College & has been interning at Integral Ad Science for close to a year now, as well as running various software projects for Patina. Tahmid likes to eat good food :)",https://www.linkedin.com/in/thmd,SWE,"In order (but no dealbreakers): Industry mentors, industry mentees, mentors, mentee",,,,, | ||
| 4/11/2026 11:03:07,Andrew Yu,hunter.vyb5t@gmail.com,Andrew is very passionate about learning technical subjects and finding ways to overcome obstacles. He is very curious and ambitious,,SWE ,,"I'd like to talk about goals, obstacles in the way, and pragmatic ways of achieving them. ",I would like to talk people who were previously low agency due to ADD or other afflictions but became higher agency,,, |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.