pyexcel has no attribute utils

164 Views Asked by At

I am trying to write a dictionary into a .xlsx document using the following code:

 example_dict = {"Column 1": [1, 2, 3], "Column 2": [4, 5, 6], "Column 3": [7, 8, 9]}
 cont = pyexcel.utils.dict_to_array(example_dict)
 sheet = pyexcel.Sheet(cont)
 sheet.save_as("output.xlsx")

Code reference http://docs.pyexcel.org/en/v0.1.1/tutorial.html#writing-a-single-sheet-excel-file.

I am getting the error AttributeError: 'module' object has no attribute 'utils'.

Precisely, I am trying to fill the key entries into columns rather than rows (filling by rows is the default way). I have not been able to come across anything helpful so far, and would really appreciate any help in fixing the error.

1

There are 1 best solutions below

0
sebas On

You have linked to a very old version of the pyexcel documentation (v0.1.1). You are probably using a newer version.

The current version of the documentation (v0.7.0) gives the following example to complete the same task:

a_dictionary_of_one_dimensional_arrays = {
    "Column 1": [1, 2, 3, 4],
    "Column 2": [5, 6, 7, 8],
    "Column 3": [9, 10, 11, 12],
}
sheet = pyexcel.get_sheet(adict=a_dictionary_of_one_dimensional_arrays)
sheet.save_as("output.xlsx")