Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Normalize string from webpage

Trying to normalize the string "PartII\xa0I \x96 FINANCIAL\n INFORMATION". In general, all that should be left (once non utf-8 characters are excluded) are letters, numbers and dots. Therefore the expected output is "PartII FINANCIAL INFORMATION". The text comes from this Sec form.

Solutions tried, where text is the string:

  1. text.encode('utf-8', errors='ignore').decode('utf-8')
  2. unicodedata.normalize(decoding, text)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use this it will work for you:

text.encode('ascii', errors='ignore').decode('utf-8')

also if you need to remove \n use this:

text.replace('\n', "").encode('ascii', errors='ignore').decode('utf-8')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading