iterate through a dictionary and create excel files

Viewed 29

I have a dictionary named mth_prod that looks like this:

{'2006-01-01 00:00:00': [                                         date product price  Date
  EEX French-Baseload-Month-Future                                 
  2006-01-02                        2006-01-01 00:00:00    80     2
  2006-01-03                        2006-01-01 00:00:00    80     3
  2006-01-04                        2006-01-01 00:00:00    80     4
  2006-01-05                        2006-01-01 00:00:00    80     5
  2006-01-06                        2006-01-01 00:00:00    80     6
  2006-01-09                        2006-01-01 00:00:00    80     9
  2006-01-10                        2006-01-01 00:00:00    80    10
  2006-01-11                        2006-01-01 00:00:00    80    11
  2006-01-12                        2006-01-01 00:00:00    80    12
  2006-01-13                        2006-01-01 00:00:00    80    13
  2006-01-16                        2006-01-01 00:00:00    80    16
  2006-01-17                        2006-01-01 00:00:00    80    17
  2006-01-18                        2006-01-01 00:00:00    80    18
  2006-01-19                        2006-01-01 00:00:00    80    19
  2006-01-20                        2006-01-01 00:00:00    80    20
  2006-01-23                        2006-01-01 00:00:00    80    23
  2006-01-24                        2006-01-01 00:00:00    80    24
  2006-01-25                        2006-01-01 00:00:00    80    25
  2006-01-26                        2006-01-01 00:00:00    80    26
  2006-01-27                        2006-01-01 00:00:00    80    27],
 '2006-02-01 00:00:00': [                                         date product price  Date
  EEX French-Baseload-Month-Future                                 
  2006-01-02                        2006-02-01 00:00:00    77     2
  2006-01-03                        2006-02-01 00:00:00    74     3
  2006-01-04                        2006-02-01 00:00:00    76     4
  2006-01-05                        2006-02-01 00:00:00    76     5
  2006-01-06                        2006-02-01 00:00:00    78     6
  2006-01-09                        2006-02-01 00:00:00    72     9
  2006-01-10                        2006-02-01 00:00:00    72    10
  2006-01-11                        2006-02-01 00:00:00    73    11
  2006-01-12                        2006-02-01 00:00:00    70    12
  2006-01-13                        2006-02-01 00:00:00    68    13
  2006-01-16                        2006-02-01 00:00:00    66    16
  2006-01-17                        2006-02-01 00:00:00    74    17
  2006-01-18                        2006-02-01 00:00:00    82    18
  2006-01-19                        2006-02-01 00:00:00    80    19
  2006-01-20                        2006-02-01 00:00:00    86    20
  2006-01-23                        2006-02-01 00:00:00    79    23
  2006-01-24                        2006-02-01 00:00:00    71    24
  2006-01-25                        2006-02-01 00:00:00    73    25
  2006-01-26                        2006-02-01 00:00:00    76    26
  2006-01-27                        2006-02-01 00:00:00    72    27
  2006-01-30                        2006-02-01 00:00:00    78    30
  2006-01-31                        2006-02-01 00:00:00    78    31
  2006-02-01                        2006-02-01 00:00:00    78    32
  2006-02-02                        2006-02-01 00:00:00    78    33
  2006-02-03                        2006-02-01 00:00:00    78    34
  2006-02-06                        2006-02-01 00:00:00    78    37
  2006-02-07                        2006-02-01 00:00:00    78    38
  2006-02-08                        2006-02-01 00:00:00    78    39
  2006-02-09                        2006-02-01 00:00:00    78    40
  2006-02-10                        2006-02-01 00:00:00    78    41
  2006-02-13                        2006-02-01 00:00:00    78    44
  2006-02-14                        2006-02-01 00:00:00    78    45
  2006-02-15                        2006-02-01 00:00:00    78    46
  2006-02-16                        2006-02-01 00:00:00    78    47
  2006-02-17                        2006-02-01 00:00:00    78    48
  2006-02-20                        2006-02-01 00:00:00    78    51
  2006-02-21                        2006-02-01 00:00:00    78    52
  2006-02-22                        2006-02-01 00:00:00    78    53
  2006-02-23                        2006-02-01 00:00:00    78    54
  2006-02-24                        2006-02-01 00:00:00    78    55],...}

Each key/value pairs is a dataframe with columns name EEX French-Baseload-Month-Future, date product, price, Date respectively. I would like to iterate over the dictionary and export each data frame as xlsx in a speciifc folder. With file name the corresponding dict key.

The result folder should look like this.

\my_foder\
          2006-01-01 00:00:00.xlsx
          2006-02-01 00:00:00.xlsx
          .
          .
          . 

Thanks in advance!

0 Answers
Related