Skip to content

Commit

Permalink
Adding url support for add_record
Browse files Browse the repository at this point in the history
  • Loading branch information
lcsrodriguez committed Jul 20, 2022
1 parent a8b8430 commit 1fbb9c7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions headat/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np
import pandas as pd
import pyspark
from urllib.parse import urlparse
import wfdb as wf
from wfdb.io.convert import wfdb_to_wav, wfdb_to_edf
import scipy.io
Expand Down Expand Up @@ -130,10 +131,23 @@ def add_record(self, record: str = None) -> bool:
# TODO Check if the domain is physionet.org with urlparse (after the check by validators)
# TODO Check if we download the data, in a specified folder
# TODO Use of PycURL for statistics on request latencies
# Checking if the record name is an URL
if validators.url(record):
url = urlparse(record)
print(f"URL : {url}")
# Restriction to the physionet.org webpages
if "https://" in record:
if "physionet.org" in record:
# We download the file
print("ok")
else:
raise ValueError("Headat only covers the 'physionet.org' web resources.")
else:
raise ValueError("Headat only covers HTTPS protocol for web resources.")
# TODO Download the files
# TODO Create a samples/ folder within the self.folder_name
pass
# If not, it's a local file and we simply read it using wfdb
else:
read_rec = wf.rdsamp(record)

Expand Down

0 comments on commit 1fbb9c7

Please sign in to comment.