Skip to content

Commit

Permalink
remove clutter, reorganise imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jgriesfeller committed Dec 6, 2023
1 parent 08eeb53 commit c05cd95
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/pyaro_readers/aeronetsunreader/AeronetSunTimeseriesReader.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import csv
from io import BytesIO
from urllib.parse import urlparse
from urllib.request import urlopen
from zipfile import BadZipFile, ZipFile

import geocoder
import numpy as np
import requests
from pyaro.timeseries import (
AutoFilterReaderEngine,
Data,
Engine,
Flag,
NpStructuredData,
Station,
)
from pyaro.timeseries import (AutoFilterReaderEngine, Data, Engine, Flag,
NpStructuredData, Station)
from tqdm import tqdm

# default URL
Expand Down Expand Up @@ -76,10 +73,6 @@ def __init__(

# check if file is a URL
if self.is_valid_url(self._filename):
from io import BytesIO
from urllib.request import urlopen
from zipfile import ZipFile

# try to open as zipfile
try:
r = requests.get(self._filename)
Expand All @@ -89,7 +82,7 @@ def __init__(
lines = [line.decode("utf-8") for line in response.readlines()]
# read only 1st file here
break
except:
except BadZipFile:
response = urlopen(self._filename)
lines = [line.decode("utf-8") for line in response.readlines()]

Expand All @@ -105,10 +98,8 @@ def __init__(
crd = csv.DictReader(lines, fieldnames=self._fields, **csvreader_kwargs)
bar = tqdm(total=len(lines))
for _ridx, row in enumerate(crd):
# if _ridx % PG_UPDATE_LINES == 0:
bar.update(1)
if row[SITE_NAME] != _laststatstr:
# print(f"reading station {row[SITE_NAME]}...")
_laststatstr = row[SITE_NAME]
# new station
station = row[SITE_NAME]
Expand Down

0 comments on commit c05cd95

Please sign in to comment.