Skip to content

Commit 466ced9

Browse files
committed
Add version update to script and missing dependencies
1 parent 41483f4 commit 466ced9

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

datapackage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"title": "SMDG Master Terminal Facilities List",
44
"description": "Code list for terminal facilities built as an extension to UN/LOCODE",
55
"homepage": "http://smdg.org/index.php/smdg-code-lists/",
6-
"version": "202501.14",
6+
"version": "20250716",
77
"licenses": [
88
{
99
"name": "ODC-PDDL-1.0",

scripts/process.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
import requests
33
import pandas as pd
4+
import re
5+
import json
46

57
from bs4 import BeautifulSoup
68

@@ -27,6 +29,20 @@ def get_link():
2729
soup = BeautifulSoup(response.text, 'html.parser')
2830
link = soup.find_all('a', {'class': 'mtli_attachment'})
2931
link = link[0].get('href')
32+
# Extract the date using regex
33+
date_match = re.search(r'v(\d{8})\.xlsx', link)
34+
if date_match:
35+
new_version = date_match.group(1)
36+
dpfile = 'datapackage.json'
37+
with open(dpfile, 'r', encoding='utf-8') as f:
38+
datapackage = json.load(f)
39+
40+
old_version = datapackage.get('version', 'unknown')
41+
datapackage['version'] = new_version
42+
43+
with open(dpfile, 'w', encoding='utf-8') as f:
44+
json.dump(datapackage, f, indent=2, ensure_ascii=False)
45+
3046
return link
3147

3248
def retrieve_content(link):
@@ -49,7 +65,7 @@ def convert_dms(dms):
4965
degrees = int(dms_values[0])
5066
minutes = int(dms_values[1])
5167
seconds = float(dms_values[2])
52-
68+
5369
return dms_to_decimal(degrees, minutes, seconds, direction)
5470

5571
def transform_csv():
@@ -76,4 +92,4 @@ def clean_up():
7692
link = get_link()
7793
retrieve_content(link)
7894
transform_csv()
79-
clean_up()
95+
clean_up()

scripts/requirements.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
requests==2.32.4
22
openpyxl==3.1.5
33
pandas==2.2.3
4-
beautifulsoup4==4.12.3
4+
beautifulsoup4==4.12.3
5+
certifi==2025.8.3
6+
et-xmlfile==2.0.0
7+
idna==3.10
8+
numpy==2.3.2
9+
python-dateutil==2.9.0.post0
10+
pytz==2025.2
11+
six==1.17.0
12+
urllib3==2.5.0

0 commit comments

Comments
 (0)