Repository: electricitymaps/electricitymaps-contrib

Issue:
Moldova repeated ValueError
Seen on the Kibana dashboard.

[Logger](https://kibana.electricitymap.org/app/kibana#/discover/1710fdd0-2460-11e8-a779-9d01de8d7a71?_g=(refreshInterval:('$$hashKey':'object:6765',display:'10%20seconds',pause:!f,section:1,value:10000),time:(from:'2018-03-10T00:00:00.000Z',mode:absolute,to:'2018-03-12T10:40:25.571Z'))&_a=(columns:!(level,extra.path,message),filters:!(('$state':(store:appState),exists:(field:level),meta:(alias:!n,disabled:!f,index:'93e631f0-245f-11e8-a779-9d01de8d7a71',key:level,negate:!f,type:exists,value:exists)),('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'93e631f0-245f-11e8-a779-9d01de8d7a71',key:level,negate:!t,params:(query:INFO,type:phrase),type:phrase,value:INFO),query:(match:(level:(query:INFO,type:phrase)))),('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'93e631f0-245f-11e8-a779-9d01de8d7a71',key:extra.key,negate:!f,params:(query:MD,type:phrase),type:phrase,value:MD),query:(match:(extra.key:(query:MD,type:phrase))))),index:'93e631f0-245f-11e8-a779-9d01de8d7a71',interval:auto,query:(language:lucene,query:''),sort:!('@timestamp',desc)))
```
Traceback (most recent call last):
  File "feeder_electricity.py", line 176, in fetch_exchange
    objs = parser(country_code1, country_code2, session, logger=public_logger)
  File "/home/electricitymap/parsers/MD.py", line 113, in fetch_exchange
    exchange_status = get_data(session=session)
  File "/home/electricitymap/parsers/MD.py", line 31, in get_data
    data = [float(i) for i in raw_data.split(',')]
  File "/home/electricitymap/parsers/MD.py", line 31, in <listcomp>
    data = [float(i) for i in raw_data.split(',')]
ValueError: could not convert string to float:
```

```
Traceback (most recent call last):
  File "feeder_electricity.py", line 148, in fetch_production
    objs = parser(country_code, session, logger=public_logger)
  File "/home/electricitymap/parsers/MD.py", line 69, in fetch_production
    grid_status = get_data(session=session)
  File "/home/electricitymap/parsers/MD.py", line 31, in get_data
    data = [float(i) for i in raw_data.split(',')]
  File "/home/electricitymap/parsers/MD.py", line 31, in <listcomp>
    data = [float(i) for i in raw_data.split(',')]
ValueError: could not convert string to float:
```


Discussion:
One thing that I had noticed for MD in the past: 
On some days, you could observe a smooth curve in the history, where exchanges from UA -> MD were just "filling up" to the local demand of MD. But sometimes, the exchange was heavily zig-zagging or going "on" and "off" again, which wouldn't make sense, because none of the generation in MD was ramping up and down so fast. Not sure if this is related to the issue, though.
Another point is that there usually were exchanges with direction UA -> MD all the time through the winter. According to hourly physical flow data on ENTSO-E, flows with direction MD -> UA were present for longer periods in the last days. Maybe it's a "-" on moldelectrica site ([for exports](http://www.moldelectrica.md/ro/activity/system_state)), that is causing the string-to-float issue?

Resolving patch:
diff --git a/parsers/MD.py b/parsers/MD.py
--- a/parsers/MD.py
+++ b/parsers/MD.py
@@ -25,9 +25,10 @@ def get_data(session=None):
 
     s = session or requests.Session()
 
+    #In order for the data url to return data, cookies from the display url must be obtained then reused.
+    response = s.get(display_url)
     data_response = s.get(data_url)
     raw_data = data_response.text
-
     data = [float(i) for i in raw_data.split(',')]
 
     return data


Test patch: