ADD Postal Code, TODO
This commit is contained in:
parent
e0bc13d092
commit
d9a97b8e66
20
afu/.post_code
Normal file
20
afu/.post_code
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
2345 Brunn/Gebirge#Brunn am Gebirge
|
||||||
|
2431 Kleinneusiedl
|
||||||
|
2560 Berndorf
|
||||||
|
3813 Dietmanns
|
||||||
|
4020 Linz|Humboldtstraße
|
||||||
|
4871 Pfaffing|Tiefenbach 6
|
||||||
|
5023 Salzburg|Langmoosweg 5
|
||||||
|
5300 Hallwang|Bäckerweg 7
|
||||||
|
6393 St Ulrich|Dorfstr 13#St. Ulrich am Pillersee#Dorfstraße 13%JN67gm86ut
|
||||||
|
7323 Ritzing
|
||||||
|
8051 Graz|Wienerstrasse 256/41
|
||||||
|
8054 Graz|Dr.Lemisch-Strasse 19#Graz#Doktor-Lemisch-Straße 19
|
||||||
|
8430 Leibnitz|Kittenberg 7
|
||||||
|
8438 Mayrhofen|Hochsteeg 589#Mayrhofen#Hochsteg 589
|
||||||
|
8453 St.Johann I.S.
|
||||||
|
8561 Söding|Steinstraße 10
|
||||||
|
8972 Ramsau Am Dachstein#Ramsau am Dachstein
|
||||||
|
9020 Klagenfurt|Feldhofg 75#Klagenfurt#Feldhofgasse 75
|
||||||
|
9500 Villach|Kiesweg 4/2
|
||||||
|
9580 Drobollach#Drobollach#Raimund-Kalcher-Straße 4
|
@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS `callbook_user`(
|
|||||||
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
`created_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
`modified_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
`modified_by` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
`active` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`active` TINYINT(1) NOT NULL DEFAULT 1 COMMENT 'the user is active',
|
||||||
`inactive` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`inactive` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
`address_id` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'link to id of callbook_adress',
|
`address_id` INT(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'link to id of callbook_adress',
|
||||||
PRIMARY KEY(`id`)
|
PRIMARY KEY(`id`)
|
||||||
@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS `callbook_address`(
|
|||||||
`address` VARCHAR(200) NOT NULL DEFAULT '' COMMENT 'original address from the import',
|
`address` VARCHAR(200) NOT NULL DEFAULT '' COMMENT 'original address from the import',
|
||||||
`postal_code` VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'also known as Zip code, "Postleitzahl"',
|
`postal_code` VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'also known as Zip code, "Postleitzahl"',
|
||||||
`org_city` VARCHAR(200) NOT NULL DEFAULT '' COMMENT 'original city from the import',
|
`org_city` VARCHAR(200) NOT NULL DEFAULT '' COMMENT 'original city from the import',
|
||||||
`city` VARCHAR(200) NOT NULL DEFAULT '' COMMENT 'original city from the import',
|
`city` VARCHAR(200) NOT NULL DEFAULT '' COMMENT 'calculated city from the original city',
|
||||||
`federal_state_code` TINYINT NOT NULL DEFAULT -1
|
`federal_state_code` TINYINT NOT NULL DEFAULT -1
|
||||||
COMMENT 'Austria: 0...outside, 1...Vienna, 2...Salzburg, 3...Lower Austria, 4...Burgenland, 5...Upper Austria, 6...Styria, 7...Tyrol, 8...Carinthia, 9...Vorarlberg',
|
COMMENT 'Austria: 0...outside, 1...Vienna, 2...Salzburg, 3...Lower Austria, 4...Burgenland, 5...Upper Austria, 6...Styria, 7...Tyrol, 8...Carinthia, 9...Vorarlberg',
|
||||||
`lat` DOUBLE NOT NULL DEFAULT 0.0 COMMENT 'latitude',
|
`lat` DOUBLE NOT NULL DEFAULT 0.0 COMMENT 'latitude',
|
||||||
|
@ -329,6 +329,31 @@ def fix_typo(call, fullname, verbose=1):
|
|||||||
fix_typo.lines = None
|
fix_typo.lines = None
|
||||||
fix_typo.spaces = []
|
fix_typo.spaces = []
|
||||||
|
|
||||||
|
def isinteger(s):
|
||||||
|
for char in s:
|
||||||
|
if not char.isdigit():
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def call_change_city(location):
|
||||||
|
match location:
|
||||||
|
case 'Groß Schweinbarth':
|
||||||
|
city = location
|
||||||
|
postal_code = 2221
|
||||||
|
|
||||||
|
|
||||||
|
def call_postal_code(location):
|
||||||
|
|
||||||
|
if location == '' or location[0] == '*':
|
||||||
|
return ''
|
||||||
|
p = location.split(' ',1)
|
||||||
|
if isinteger(p[0]) and int(p[0]) > 1000 and int(p[0]) < 10000:
|
||||||
|
postal_code = p[0]
|
||||||
|
city = p[1]
|
||||||
|
else:
|
||||||
|
postal_code, city = call_change_city(location)
|
||||||
|
return postal_code
|
||||||
|
|
||||||
def call_data_record(line, mod_date, verbose, cur):
|
def call_data_record(line, mod_date, verbose, cur):
|
||||||
|
|
||||||
# we have to split the record with a cost-intensive regular expression
|
# we have to split the record with a cost-intensive regular expression
|
||||||
@ -381,26 +406,36 @@ def call_data_record(line, mod_date, verbose, cur):
|
|||||||
print(f'Call: {call}, Name: {fullname}, Gender: {gender}')
|
print(f'Call: {call}, Name: {fullname}, Gender: {gender}')
|
||||||
else:
|
else:
|
||||||
print(f'Call: {call}, First Name: {firstname}, Surname: {surname}, Gender: {gender}')
|
print(f'Call: {call}, First Name: {firstname}, Surname: {surname}, Gender: {gender}')
|
||||||
|
|
||||||
print(f'Location: {location}, Address: {address}, Permit: {permit_class}')
|
print(f'Location: {location}, Address: {address}, Permit: {permit_class}')
|
||||||
|
|
||||||
created = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
created = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||||
call_data_record.cnt += 1 # increment the User_id
|
call_data_record.cnt += 1 # increment the User_id
|
||||||
user_id = call_data_record.cnt
|
user_id = call_data_record.cnt
|
||||||
# print(created)
|
|
||||||
statement = "INSERT INTO `callbook_user`(`user_id`,`call`,`firstname`,`surname`,`gender`,`created`,`modified`) VALUES (%s, %s, %s, %s, %s, %s, %s)"
|
|
||||||
data = (user_id,call,firstname,surname,gender,created,created)
|
|
||||||
|
|
||||||
try:
|
statement = f'SELECT `call`, `firstname`, `surname`, `gender` FROM `callbook_user` WHERE `call` = "{call}" AND `active` = 1'
|
||||||
# cur.execute(f"INSERT INTO `callbook_user` (`call`,`firstname`,`surname`,\
|
cur.execute(statement)
|
||||||
# `created`,`created_by`,`modified`,`modified_by`,`active`)\
|
result = cur.fetchall()
|
||||||
# VALUES ('{call}','{firstname}','{surname}','{created}','0','{created}','0','{created}');")
|
if not result:
|
||||||
# cur.execute(f'INSERT INTO `callbook_user` (`call`) VALUES ("{call}");')
|
postal_code = call_postal_code(location)
|
||||||
cur.execute(statement, data)
|
statement = "INSERT INTO `callbook_address`(`location`,`address`,`postal_code`) VALUES (%s,%s,%s)"
|
||||||
except mariadb.Error as e:
|
data = (location,address,postal_code)
|
||||||
print(f'\n[WARN] MySQLError during execute statement\n\tArgs: {e.args}')
|
try: cur.execute(statement, data)
|
||||||
except Exception as e:
|
except mariadb.Error as e:
|
||||||
print('Error: {}'.format(e), file=sys.stderr)
|
print(f'\n[WARN] MySQLError during execute statement\n\tArgs: {e.args}')
|
||||||
|
except Exception as e:
|
||||||
|
print('Error: {}'.format(e), file=sys.stderr)
|
||||||
|
|
||||||
|
statement = "INSERT INTO `callbook_user`(`user_id`,`call`,`firstname`,`surname`,`gender`,`created`,`modified`,`address_id`) VALUES (%s, %s, %s, %s, %s, %s, %s, LAST_INSERT_ID())"
|
||||||
|
data = (user_id,call,firstname,surname,gender,created,created)
|
||||||
|
try:
|
||||||
|
cur.execute(statement, data)
|
||||||
|
except mariadb.Error as e:
|
||||||
|
print(f'\n[WARN] MySQLError during execute statement\n\tArgs: {e.args}')
|
||||||
|
except Exception as e:
|
||||||
|
print('Error: {}'.format(e), file=sys.stderr)
|
||||||
|
else:
|
||||||
|
for r in result:
|
||||||
|
print(f'Call: {call} {firstname} {surname} {gender} <- ')
|
||||||
|
|
||||||
call_data_record.cnt = 0
|
call_data_record.cnt = 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user