Skip to content

Instantly share code, notes, and snippets.

@imclint21
Created March 31, 2021 18:09
Show Gist options
  • Save imclint21/5c287c6bac6bfd39908ca85326f2e00c to your computer and use it in GitHub Desktop.
Save imclint21/5c287c6bac6bfd39908ca85326f2e00c to your computer and use it in GitHub Desktop.
using System.IO;
using System.Collections.Generic;
using System.Globalization;
using CsvHelper;
using Newtonsoft.Json;
namespace JsonToCsv
{
public class Program
{
private static void Main()
{
var leads = JsonConvert.DeserializeObject<IEnumerable<Lead>>(File.ReadAllText("INPUT.txt"));
using var writer = new StreamWriter("OUTPUT.csv");
using var csv = new CsvWriter(writer, CultureInfo.InvariantCulture);
csv.WriteRecords(leads);
}
}
public class Lead
{
public string ProfilePicture { get; set; }
public string Username { get; set; }
public string Fullname { get; set; }
public string Biography { get; set; }
public string PhoneNumber { get; set; }
public string Email { get; set; }
public long MediaCount { get; set; }
public long Followers { get; set; }
public long Followings { get; set; }
public string ExternalUrl { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment