Solar Generation 2 ================== We have a text file with information about the power generated by a solar plant. Each line contains the data corresponding to a solar panel. It includes the following data separated by ``';'`` : - the *group id* of the group the solar panel belongs to - its *location* inside the group - its *status* (whether is ``'on'`` or ``'off'``) - a *sequence of measures* of the power generated by that panel at different times: each measure is either a :class:`float` value, or the string ``'*'`` if the measurement system failed. For example, see the first 5 lines of (first 5 panels) of the file :download:`solargen_data.txt `: .. literalinclude:: solargen_data.txt :language: text :lines: 1-5 Notice that the panel ``'3-15'`` in group ``'gA'`` generated :math:`3.5+2.5+4.0+7.0+3.2+4.0 = 24.2` kWh, and the total generated by group ``'gA'`` is :math:`= 55.9` kWh ( :math:`24.2` from panel ``'3-15'`` plus :math:`31.7` from panel ``'3-17'``, and nothing from panel ``'3-16'`` since it is ``off``). solar panel You are required to implement the following functions in the module :mod:`solargen2.py` (file :file:`solargen2.py`): .. note:: First function weights 75% and second 25%. The first function is .. py:function:: solargen_sum(fnamein, fnameout) such that **given** two :class:`str` with the names of two files, ``fnamein`` a file with data from a solar generation plant as described above, and ``fnameout`` a non-existing file, **writes** a file named ``fnameout`` which contains a line for each line in the input file that is ``'on'``, with the follwing information for each line: - the group id - the location - the number of measures of that location (those that are not an ``'*'``) - the power produced by that solar panel (the sum of all its measures that not an ``'*'``) For instance, the call ``solargen_sum('solargen_data.txt', 'solargen_sum_out.txt')`` should write the file ``solargen_sum_out.txt`` with the following info: .. literalinclude:: solargen_sum_out.txt :language: python3 A doctest file is available at :download:`solargen_sum-test.txt `. -------------------------------------------------------------------------------- The second function is .. py:function:: solargen_sum_ordered(fnamein, fnameout) that does the same than ``solargen_sum(fnamein, fnameout)`` but the lines are ordered according to the following criteria: #. Alphabetically ordered by the **group id**. #. Decreasing order of the **power produced**. For instance, the call ``solargen_sum('solargen_data.txt', 'solargen_sum_ordered_out.txt')`` should write the file ``solargen_sum_ordered_out.txt`` with the following info: .. literalinclude:: solargen_sum_ordered_out.txt :language: python3 A doctest file is available at :download:`solargen_sum_ordered-test.txt `.