load

Read dictionary from file into original lists

Read dictionary from file into original lists Question: I have one nested list, and one list for "numbers" test_keys = [["tobbe", "kalle"],["karl", "Clara"],["tobbe"],["tank"]] test_values = [‘123’, ‘234’,’345′,’456′] res = {} for key in test_keys: for value in test_values: res[value] = key test_values.remove(value) break with open("myfile.txt", ‘w’) as f: for key, value in res.items(): f.write(‘%s;%s;n’ % …

Total answers: 1

Python Pandas does not read the first row of csv file

Python Pandas does not read the first row of csv file Question: I have a problem with reading CSV(or txt file) on pandas module Because numpy’s loadtxt function takes too much time, I decided to use pandas read_csv instead. I want to make a numpy array from txt file with four columns separated by space, …

Total answers: 2

recover dict from 0-d numpy array

recover dict from 0-d numpy array Question: What happened is that I (by mistake) saved a dictionary with the command numpy.save() (no error messages shown) and now I need to recover the data in the dictionary. When I load it with numpy.load() it has type (numpy.ndarray) and is 0-d, so it is not a dictionary …

Total answers: 3

Can I get JSON to load into an OrderedDict?

Can I get JSON to load into an OrderedDict? Question: Ok so I can use an OrderedDict in json.dump. That is, an OrderedDict can be used as an input to JSON. But can it be used as an output? If so how? In my case I’d like to load into an OrderedDict so I can …

Total answers: 6