How to split multiple values from string text and calculate them

For text files with mixed alphanumeric values, they can be copied into excel and then disassembled, but the formula is too complex for ordinary people to master. This problem can also be solved with VBA, Java, Python and other development languages, but the code is tedious, and it is more difficult to use the hard to understand regular expression.

It would have been much simpler if you had used esProc. For example, one line of the text file is "Jeff spent 13.5$ for cola, 5.2$ for coat, and 21$ for toys". To sum all the values in the file, the esProc code can be written as follows:





/ Read the text to form a large string



/ Disassemble all values, including decimals




If we do not sum the whole file, but sum the lines, the code is also very simple:





/ Read text, one string per line


/ Split by row to form two columns. The name column   stores the first (name) of the word in the row, and the numbers column stores   the value



/ Add a new column to sum the numbers

esProc is a scripting language, which can be executed repeatedly in IDE, and can be called in command line mode.

Other similar file calculation examples: CSV File Comparison CSV File Comparison ]

It’s simple to deal with Excel: An Easy Way to Merge and Summarize Excel Files An Easy Way to Merge and Summarize Excel Files ]

Here are more examples of text calculation, covering the common operations of structured data: Structured Text Computing with esProc

esProc is a professional file processing script. It is easy to install and use, easy to debug, and rich in class libraries. For details, please refer to:

Read Getting Started with esProc to download and install esProc, get a license for free and find related documentation.