J'ai désérialisé en C# un fichier JSON avec la structure de données suivante
[DataContract]
public class SentimentData
{
[DataMember(Name ="Column1")]
public IEnumerable<string> Column1 { get; set; }
[DataMember(Name ="Column-2")]
public IEnumerable<string> Column2 { get; set; }
}
Le compte de la colonne 1 n'est pas égal au compte de la colonne 2. Je veux juste vider toutes les données de la colonne 1 dans la première colonne et les données de la colonne 2 dans la deuxième colonne. J'ai essayé ce qui suit mais cela ne fonctionne pas.
using (var writer = new StreamWriter(@"C:\test.csv"))
{
var nr = column1data.Select(y => new { Column1= y }).ToList();
//var nnr = column2data.Select(y => new { Column2 = y }).ToList();
var csv = new CsvWriter(writer);
csv.WriteRecords(nr);
//csv.WriteRecords(nnr);
writer.Flush();
}
Quelqu'un peut-il savoir comment faire ?
échantillon json :
{
"Negative": [
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt"
],
"Non-Negative": [
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt",
"a.txt",
"b.txt"
]
}