Skip to content

Commit 17e208e

Browse files
committed
use StringIO
1 parent d1dae9a commit 17e208e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/atomistics/referencedata/wikipedia.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from io import StringIO
2+
13
import pandas
24
import requests
35

@@ -33,7 +35,7 @@ def get_elastic_properties(chemical_symbol: str) -> dict:
3335
"https://en.wikipedia.org/wiki/Elastic_properties_of_the_elements_(data_page)",
3436
headers={"User-Agent": "atomistics package"},
3537
)
36-
df_lst = pandas.read_html(response.text)
38+
df_lst = pandas.read_html(StringIO(response.text))
3739
property_dict = {}
3840
for i, p in enumerate(property_lst):
3941
df_tmp = df_lst[i]

src/atomistics/referencedata/wolframalpha.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from io import StringIO
23
from typing import Callable, Optional, Union
34

45
import numpy as np
@@ -17,7 +18,7 @@ def _get_content_from_url(url: str) -> pandas.DataFrame:
1718
Returns:
1819
pandas.DataFrame: The content retrieved from the URL as a pandas DataFrame.
1920
"""
20-
content = pandas.read_html(requests.get(url).text)
21+
content = pandas.read_html(StringIO(requests.get(url).text))
2122
if len(content[8]) > 1:
2223
return content[8]
2324
else:

0 commit comments

Comments
 (0)