Skip to content

Commit 4c89573

Browse files
authored
Merge pull request #15 from rsignell-usgs/auth
use requests before read_csv to get auth
2 parents 99d990c + fa72459 commit 4c89573

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

erddapy/erddapy.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import (absolute_import, division, print_function)
22

3+
import requests
4+
35
try:
46
from urllib.parse import quote_plus
57
except ImportError:
@@ -273,16 +275,20 @@ def get_var_by_attr(self, dataset_id, **kwargs):
273275
['latitude', 'longitude', 'time', 'depth']
274276
275277
"""
278+
from io import StringIO
279+
276280
try:
277281
import pandas as pd
282+
278283
except ImportError:
279284
raise ImportError('pandas is needed to use `get_var_by_attr`.')
280285
info_url = self.get_info_url(dataset_id, response='csv')
281286

282287
# Creates the variables dictionary for the `get_var_by_attr` lookup.
283288
if not self._variables or self._dataset_id != dataset_id:
284289
variables = {}
285-
_df = pd.read_csv(info_url)
290+
r = requests.get(info_url, verify=True)
291+
_df = pd.read_csv(StringIO(r.text))
286292
self._dataset_id = dataset_id
287293
for variable in set(_df['Variable Name']):
288294
attributes = _df.loc[

0 commit comments

Comments
 (0)