File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 44import pandas as pd
55import logging
66import os
7- from urllib . request import urlretrieve
7+ import requests
88
99try :
1010 from matplotlib import pyplot as plt
@@ -44,8 +44,9 @@ def download_file(filename, url):
4444 if not os .path .isfile (filename ):
4545 logging .info ('Copying weather data from {0} to {1}' .format (
4646 url , filename ))
47- urlretrieve (url , filename )
48-
47+ req = requests .get (url )
48+ with open (filename , 'wb' ) as fout :
49+ fout .write (req .content )
4950
5051def fetch_example_files ():
5152 basic_path = os .path .join (os .path .expanduser ("~" ), '.oemof' )
Original file line number Diff line number Diff line change 33import logging
44import numpy as np
55import pandas as pd
6- from urllib . request import urlretrieve
6+ import requests
77
88
99class SimpleWindTurbine :
@@ -326,7 +326,9 @@ def read_wpp_data(**kwargs):
326326 if not os .path .exists (cp_path ):
327327 os .makedirs (cp_path )
328328 if not os .path .isfile (filepath + suffix ):
329- urlretrieve (url + suffix , filepath + suffix )
329+ req = requests .get (url + suffix )
330+ with open (filepath + suffix , 'wb' ) as fout :
331+ fout .write (req .content )
330332 logging .info ('Copying cp_values from {0} to {1}' .format (
331333 url , filepath + suffix ))
332334 logging .debug ('Retrieving cp values from {0}' .format (
@@ -339,7 +341,9 @@ def read_wpp_data(**kwargs):
339341 logging .debug ('Retrieving cp values from {0}' .format (
340342 filename + suffix ))
341343 if not os .path .isfile (filename + suffix ):
342- urlretrieve (url + suffix , filename + suffix )
344+ req = requests .get (url + suffix )
345+ with open (filename + suffix , 'wb' ) as fout :
346+ fout .write (req .content )
343347 logging .info ('Copying cp_values from {0} to {1}' .format (
344348 url , filename + suffix ))
345349 df = pd .read_csv (filename + suffix , index_col = 0 )
You can’t perform that action at this time.
0 commit comments