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

Android Java.Lang.RuntimeException : Unable to start activity Component Info -

php - htaccess subdomain and directory redirect -

c# - Sort XmlNodeList with a specific Node value -