Skip to content

Commit bcc84d1

Browse files
authored
Merge pull request #302 from SPARCS-UP-Mindanao/268-be-create-python-script-to-migrate-pre-registrations-from-csv
fix: phone number data cleaning
2 parents 1ea8ff9 + 4fd9394 commit bcc84d1

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

backend/scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.csv

backend/scripts/import_pre_registration_from_csv.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class DevFestPreRegistrationSchema(BaseModel):
5757
phone_number: str = Field(
5858
None,
5959
title=DevFestColumns.PHONE_NUMBER,
60-
regex=r'^(09)\d{9}$', # Philippine mobile number
6160
)
6261
career_status: Optional[CareerStatus] = Field(None, title=DevFestColumns.CAREER_STATUS)
6362
developer_status: Optional[DeveloperStatus] = Field(None, title=DevFestColumns.DEVELOPER_STATUS)
@@ -86,6 +85,12 @@ def strip_and_clean_phone_number(cls, value):
8685

8786
value = re.sub(r'\D', '', value)
8887

88+
if re.match(r'^(63)\d{10}$', value):
89+
value = '0' + value[2:]
90+
91+
if re.match(r'^9\d{9}$', value):
92+
value = '0' + value
93+
8994
return value
9095

9196

@@ -201,6 +206,6 @@ def import_pre_registration_from_csv(eventId: str, csv_file_path: str = 'input.c
201206

202207

203208
if __name__ == '__main__':
204-
event_id = 'testevent'
209+
event_id = 'event_id'
205210
csv_file_path = 'scripts/input.csv'
206211
import_pre_registration_from_csv(eventId=event_id, csv_file_path=csv_file_path)

0 commit comments

Comments
 (0)