Skip to content

Instantly share code, notes, and snippets.

@scichelli
Created March 18, 2015 22:06
Show Gist options
  • Save scichelli/5a123baac52c0f224df9 to your computer and use it in GitHub Desktop.
Save scichelli/5a123baac52c0f224df9 to your computer and use it in GitHub Desktop.
Parse the JSON of GitHub's issues into a pipe-delimited file for importing into a spreadsheet application
namespace IssuesList
{
using System;
using System.Linq;
using System.IO;
using System.Reflection;
using Newtonsoft.Json;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Reading file contents...");
var assembly = Assembly.GetExecutingAssembly();
const string resourceName = "IssuesList.IssuesExport.txt"; //https://api.github.com/repos/scichelli/nautilus-build/issues
using (var stream = assembly.GetManifestResourceStream(resourceName))
{
using (var reader = new StreamReader(stream))
{
using (var writer = new StreamWriter("issues.csv"))
{
var result = reader.ReadToEnd();
var issues = JsonConvert.DeserializeObject<Issue[]>(result);
foreach (var issue in issues.OrderBy(i => i.Milestone.Number).ThenBy(i => i.Number))
{
Console.WriteLine("{0}: {1} {2}", issue.Milestone.Title, issue.Number, issue.Title.Substring(0, Math.Min(issue.Title.Length, 35)));
writer.WriteLine("{0}|{1}|{2}|{3}", issue.Milestone.Number, issue.Milestone.Title, issue.Number, issue.Title);
}
Console.WriteLine(issues.Count());
}
}
}
Console.WriteLine("Finished.");
Console.ReadLine();
}
}
class Issue
{
public int Number { get; set; }
public string Title { get; set; }
public Label[] Labels { get; set; }
public Milestone Milestone { get; set; }
}
class Label
{
public string Name { get; set; }
}
class Milestone
{
public int Number { get; set; }
public string Title { get; set; }
}
}
@scichelli
Copy link
Author

Just a back-of-the-napkin amount of code to get my list into a format I could easily toss estimates onto. As Visual Studio ground itself to life, I thought, this is probably a perfect use case for scriptcs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment