Skip to content

Commit 17d9b34

Browse files
author
diamant-x
committed
Fix: str not int cast for ESP id downloader.
1 parent 1a0ca52 commit 17d9b34

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

source/data/interim/esp_PfdParserToCsvInterim.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#%% Import metadata to use
2323
dfMetadataAll = pd.read_csv(metadataFile, sep=";", header=0, dtype={"area":str})
24-
dfMetadataAll["CoreFileName"] = dfMetadataAll["File"].str.replace(startFileName,"").str.replace(endFileName,"")
24+
dfMetadataAll["CoreFileName"] = dfMetadataAll["File"].str.replace(startFileName,"").str.replace(endFileName,"").astype('int32')
2525
rawFiles = glob.glob(os.path.join(pathInputFile, startFileName+"*"+endFileName))
2626

2727
#%% Process Data Structure
@@ -41,7 +41,7 @@
4141

4242
if dfMetadata.size == 0:
4343
#Try to find the previous file metadata identified and apply same settings, if none, then skip file.
44-
coreFileName = fileName.replace(startFileName,"").replace(endFileName,"")
44+
coreFileName = int(fileName.replace(startFileName,"").replace(endFileName,""))
4545
if coreFileName < dfMetadataAll["CoreFileName"].min():
4646
print("Skipping file due to no metadata defined.")
4747
continue

source/data/raw/esp_PfdDownloader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131

3232
countFiles = 0
3333

34-
for fileId in range(numberOfDays+1): #We assume 360 reports maximum may be issued.
34+
for fileId in range(numberOfDays+1):
3535
#Get official file name to store it.
3636
fileName = startFileName+str(fileId+31)+endFileName
3737

3838
if "Error 404" in requests.get(rootURL+fileName, verify = False).text:
39+
print("Error File not Found:\t"+ fileName)
3940
continue
4041
else:
41-
print("Downloading file "+fileName)
42+
print("Downloading file:\t"+fileName)
4243
# https://stackoverflow.com/a/7244263
4344
with open(pathOutputFiles+fileName, 'wb') as out_file:
4445
out_file.write(requests.get(rootURL+fileName, verify = False).content)

0 commit comments

Comments
 (0)