Converting a csv file to json using C#

If you can use System.Web.Extensions, something like this could work: var csv = new List<string[]>(); // or, List<YourClass> var lines = System.IO.File.ReadAllLines(@”C:\file.txt”); foreach (string line in lines) csv.Add(line.Split(‘,’)); // or, populate YourClass string json = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(csv); You might have more complex parsing requirements for the csv file and you might have a class that … Read more

How to export data to a csv file with iOS?

You can also do something like: [[array componentsJoinedByString:@”,”] writeToFile:@”components.csv” atomically:YES encoding:NSUTF8StringEncoding error:NULL]; You can use combinations of this to put together a CSV (append the output of one array for the column names to one array for the values, etc). Of course, you have to be careful to put quotes around values that already contain … Read more

Convert nested JSON to CSV file in Python

Please scroll down for the newer, faster solution This is an older question, but I struggled the entire night to get a satisfactory result for a similar situation, and I came up with this: import json import pandas def cross_join(left, right): return left.assign(key=1).merge(right.assign(key=1), on=’key’, how=’outer’).drop(‘key’, 1) def json_to_dataframe(data_in): def to_frame(data, prev_key=None): if isinstance(data, dict): df … Read more

Getting “System.Collections.Generic.List`1[System.String]” in CSV File export when data is okay on screen

If an object you export as CSV with Export-Csv or ConvertTo-Csv has property values that contain a collection (array) of values, these values are stringified via their .ToString() method, which results in an unhelpful representation, as in the case of your array-valued .IPV4Addresses property. To demonstrate this with the ConvertTo-Csv cmdlet (which works analogously to … Read more