Skip to content

Commit

Permalink
import_geiq: cast the SIRET to integer before casting to string
Browse files Browse the repository at this point in the history
In the XLS, the SIRET can be of type float. When casted to string,
trailing `.0`s appear. Casting to int before str prevents this.
  • Loading branch information
EwenKorr committed Dec 20, 2024
1 parent 7cf5aa3 commit 013fd43
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion itou/companies/management/commands/import_geiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
from itou.utils.validators import validate_siret


def clean_string_siret(s):
"""
Sometimes the SIRET is saved as float in xls file.
Here we force the format to 14 characters.
"""
if s is None:
return None
return clean_string(int(s))


@timeit
def get_geiq_df(filename):
info_stats = {}
Expand Down Expand Up @@ -43,7 +53,7 @@ def get_geiq_df(filename):
df["address_line_2"] = df.address_line_2.apply(clean_string)
df["post_code"] = df.post_code.apply(clean_string)
df["city"] = df.city.apply(clean_string)
df["siret"] = df.siret.apply(clean_string)
df["siret"] = df.siret.apply(clean_string_siret)
df["auth_email"] = df.auth_email.apply(clean_string)

# "GEIQ PROVENCE" becomes "Geiq Provence".
Expand Down

0 comments on commit 013fd43

Please sign in to comment.