Skip to content

Instantly share code, notes, and snippets.

@mendesbarreto
Last active November 6, 2023 21:50
Show Gist options
  • Save mendesbarreto/07605310d17d9e37a9cca7f34bef54e5 to your computer and use it in GitHub Desktop.
Save mendesbarreto/07605310d17d9e37a9cca7f34bef54e5 to your computer and use it in GitHub Desktop.
Little script to parse the TSV provided by GitHub projects to a markdown format
import { readFileSync, writeFileSync } from 'fs';
function readGithubProjectTSV(path: string) {
const fileContent = readFileSync(path, { encoding: 'utf8' });
const rows = fileContent.split('\n');
rows.shift();
rows.sort();
console.log(rows.length);
let issueGroups: Record<string, string[]> = {};
for (let issue of rows) {
const issueComponents = issue.split('\t');
const key = issueComponents[7];
const value = `[${issueComponents[0]}](${issueComponents[1]})\n`;
if (issueGroups[key]) {
issueGroups[key].push(value);
} else {
issueGroups[key] = [value];
}
}
let markdown = '';
Object.entries(issueGroups).forEach(([key, value]) => {
markdown += `${key}: \n\n`;
value.sort();
for (let issue of value) {
markdown += issue;
}
markdown += '\n\n';
});
//console.log(markdown);
writeFileSync('githubIssuesMarkdown.md', markdown);
}
readGithubProjectTSV('github-issues.tsv');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment