Get Street and number in a string in an irregular expression

Asked

Viewed 283 times

2

I have a table that I have all the address in one column, but it is irregular. Below are some of the occurrences:

BR 459 KM 153
RODOVIA ITAJUBA MF KM 05
Rodovia MG353  2Km 55
RUA 37 QUADRA 4 LOJA 611 E 1621
Rua 13 de Maio 71C
RUA 106 Nº07
RUA 114 08

What is the most correct way to extract for these cases the Street and the Number since we have the name of the Street/ Highway with number and other information that can be discarded? Thanks in advance.

  • 2

    Without a pattern there’s no way to do it... could make a regular Expression that found the first occurrence of a number, but this can be part of the name of the street. You may have to make a dictionary of descriptions for the backyard, such as "Street, Avenue, Highway", etc to help identify the street, but even so will not have something 100% accurate to separate street and number

  • 1

    The "most correct way" is to re-register right. In your case you can automate most occurrences, and manually handle exceptions

  • 1

    Exactly, I managed to develop a provisional solution, but it is not adequate, the right would be to improve the interface allowed the entry of the data within the standard.

  • I would make a Function that would return the "broken" address in Function it is easier to treat the different cases would return either a complex type or a string seperada by commas , another application would take care of saving the data.

  • I would set up a script separating first the type of streets, example: take the first word of each occurrence, check if it was "Street", "Avenue", "Viela", "BR", "Square".... and would save in a temporary with the type. In the end I would have separated almost, or all the addresses and the ones left I would handle individually. I hope I’ve helped

  • Managed to solve?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.