python - Extract numbers with EXPONENTS from heterogeneous text file -


i need take out unformatted numerical data text file. in textfile, numbers somewhere separated single space , somewhere multiple spaces, somewhere tabs; pretty heterogeneous text :( want python ignore spaces/tabs , identify whole numerical values , put them in array/list. possible using python?

edit: there many numbers written in scientific/exponential notation e.g. 1.2345e+06, , python not recognize them numbers. \d not work :(

i don't want use normal string search purpose (given there many strings/words of no interest/use). regular expression module documentation has nothing mentioned issue.

if lines " 2.3e4 " or "2.6" or so, try:

^\s*?([+-]?\d+(\.\d+)?(e[+-]?\d+)?)\s*$ 

notice \s*? mark (non-greedy zero/more spaces). dont forget question mark there - not including question mark make capture last digit of number due greediness.

afaik python has not special symbol, other \d digits, capture numbers


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -