Jump to content
Macro Express Forums

Text File Number Average


Recommended Posts

I am trying to write a macro that reads a space delimited text file. The file has 8 columns per line. I would like it toaverage the numbers in each of the columns and then output a single line with the averaged results. The text files have 17280 lines per day, and a new one is generated every day. Does anybody have an idea as to how I may go about this?

Link to comment
Share on other sites

First you need to convert the space delimited file to a tab or comma delimited file, which is very easy to do. Simply read the file into a string variable, create a loop that converts all double spaces to a single space. Then convert all single spaces to a tab. Save the string back to a file.


Now it is just a matter of using the Process ASCII File construct. Read each line in, convert each of the string variables to decimal variables, add the decimals to the totals, and then increment the line counter.


At the end, you need to divide each of the column totals by the line counter, then save them to a file.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...