Created
March 31, 2021 18:09
-
-
Save imclint21/5c287c6bac6bfd39908ca85326f2e00c to your computer and use it in GitHub Desktop.
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
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