Created
March 18, 2015 22:06
-
-
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
This file contains 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
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; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.