Skip to content

Instantly share code, notes, and snippets.

@thangarajan8
Last active July 25, 2025 12:20
Show Gist options
  • Save thangarajan8/16c6ec4bb150dbdc5346a4d88e373d92 to your computer and use it in GitHub Desktop.
Save thangarajan8/16c6ec4bb150dbdc5346a4d88e373d92 to your computer and use it in GitHub Desktop.
to be delete
def clean_amount(value):
# Move trailing minus to the front
value = value.replace('-', '')
is_negative = value.endswith('-') or value.startswith('-')
# Remove thousand separator and convert decimal separator
value = value.replace('.', '').replace(',', '.').replace('-', '')
# Convert to float
try:
num = float(value)
return -num if is_negative else num
except ValueError:
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment