Skip to content
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

Batch Profile Update : Parse Teams #21

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Nov 5, 2022

Original issue description

Description

Every semester we spend far too much time manually entering team names, uploading them to s3 and inserting bios. This will be a script automating that whole process.

Milestone 1 : Parse CSV into teams

Begin first by making sure you can read the CSV file correctly.

💡 A CSV (comma separated values) file is a text-format for storing spreadsheet-like data. Open up the file above and compare it to the Google Spreadsheet I shared with you both. It should be identical.

Use the csv-parser library found here. I’ve already installed it into the Github repo.

Here’s a quick example script I’ve written to ensure it will work:

const fs = require("fs");
const parse = require("csv-parser");

const parser = parse({ delimiter: "," });

parser.on("readable", function () {
  let record;
  while ((record = parser.read()) !== null) {
    console.log(record);
  }
});

fs.createReadStream("./sigs.csv").pipe(parser);

Milestone Requirements

  • Read the CSV file as a list of objects
  • As you can see on the spreadsheet, there is an overall headers: (DESK, POSITION, SIGNATURE, SLUG…) and teams: (MANAGEMENT, FEATURES, ….)
    • The DESK, POSITION, SIGNATURE, SLUG… fields should be specific to each member of The Gazelle
    • Each member should be nested within a TEAM object
      • This means you’ll need to:

        • Parse the ENTIRE csv into a list of objects
        • Begin looping through all objects. When you find an object which looks like a team header, you want to nest all object after it as team members until you find the next team header, and so on:
        {
          DESK: 'MANAGEMENT',
          POSITION: '',
          'NYU EMAIL': '',
          SIGNATURE: '',
          '': '',
          Slug: ''
        }
        • A good way to identify these team headers is by if the DESK field is populated and all other fields are blank.

Functions

function readCSV(csvFile: string): returns [{}]

Reads any CSV file at the given file path provided (csvFile). Returns the elements as a list of objects. Does not do any logic parsing for teams or team members.

function parseTeams(csvDump): returns [{}]

Reads a dump of CSV objects (from readCSV) and parses all objects into a nested object (See Example Parsed Object below).

function isTeamHeader(object): returns bool

Reads a team object and returns whether an object looks like a team header or not. See above explanation for identifying team headers.

Example Parsed Object

[
	{
		team: "management",
		members: [
			{
			  DESK: 'Githmi Rabel',
			  POSITION: 'Editor-in-Chief',
			  'NYU EMAIL': '...',
			  SIGNATURE: '*Githmi Rabel is Editor-in-Chief. Email her at [email protected]*',
			  '': '',
			  Slug: 'githmi-rabel'
			},
			....
		]
	},
	{
		team: "web",
		members: [
			{
			  DESK: 'Githmi Rabel',
			  POSITION: 'Editor-in-Chief',
			  'NYU EMAIL': '...',
			  SIGNATURE: '*Githmi Rabel is Editor-in-Chief. Email her at [email protected]*',
			  '': '',
			  Slug: 'githmi-rabel'
			},
			....
		]
	},
  ....
]

closes #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batch Profile Update : Parse Teams
3 participants