4/3/2023 0 Comments Python flatten json to csvWith open(args.json_file.replace(".json", ".csv"), "w") as outputFile: # open csv fileįinal_data.to_csv(outputFile, encoding='utf8', index=False) Json_data = json.loads(inputFile.read()) # load json content With open(args.json_file, "r") as inputFile: # open json file "-j", "-json", dest="json_file", help="PATH/TO/json file to convert", metavar="FILE", required=True) Parser = argparse.ArgumentParser(description='Converting json files into csv for Tableau processing') My code, so far, looks like this: import jsonįrom pandas.io.json import json_normalize I have been basically adapting it to my problem, but it is still not working for me. I've found very helpful "flattening" json info in this blog post. I am trying to convert a nested json into a csv file, but I am struggling with the logic needed for the structure of my file: it's a json with 2 objects and I would like to convert into csv only one of them, which is a list with nesting.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |