Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to save dictionary
#1
I wrote a code to load json contents. How should I modify this to save it as a dictionary or even save it as a data frame?

import json
import traceback
import pandas as pd

def read_json_file(fname):
    with open(fname, "r") as f:
        try:
            return json.load(f)
        except Exception as e:
            print ("Error parsing %s" %fname)
            traceback.print_exc()
            raise e
print(read_json_file("/Desktop/file1.txt"))
Reply


Messages In This Thread
How to save dictionary - by sampitosh - Apr-23-2020, 06:05 PM
RE: How to save dictionary - by ndc85430 - Apr-23-2020, 06:10 PM
RE: How to save dictionary - by sampitosh - Apr-23-2020, 06:37 PM
RE: How to save dictionary - by ndc85430 - Apr-24-2020, 04:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to save to multiple locations during save cubangt 1 608 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  Simple Dictionary save and recover Astrikor 12 6,129 Aug-22-2018, 06:51 AM
Last Post: Astrikor

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020