Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9233719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:37:15+00:00 2026-06-18T06:37:15+00:00

I am a new user in powershell. I have like 30 files with the

  • 0

I am a new user in powershell. I have like 30 files with the similar data set with three columns. The columns data are Lat Long Value. It also has a header as shown below. However, the columns are not labeled.

The sample data looks like this :

* , Water Column, Depth Averaged
   437416.450  3350091.975        0.000
   437379.500  3350133.550        0.000
   437583.925  3350278.375        0.000
   437545.475  3350312.800        0.000
   437768.700  3350492.125        0.000
   437730.675  3350525.050        0.000
   437919.750  3350668.850        0.000
   437883.350  3350701.150        0.000
   438072.475  3350836.850        0.000
   438039.500  3350871.075        0.000
   438221.250  3350960.400        0.000
   438189.300  3351005.500        0.000
   438381.025  3351048.025        0.000
   438346.900  3351107.250        0.000
   438588.600  3351155.800        0.000
   438548.000  3351225.825        0.000
   438802.400  3351278.925        0.002
   438753.750  3351354.150        0.001
   439000.525  3351414.850        0.013
   438946.625  3351488.475        0.009
   439181.000  3351557.950        0.064
   439126.725  3351626.025        0.048
   439361.600  3351708.700        0.277
   439308.550  3351773.525        0.227

I want to calculate the average of value of each row from all the files in the same folder. Basically, the first row will have an average of 30 data points from 30 files. I thought powershell might be able to do with a simple algorithm.

I found a similar post calculating average using awk from multiple files on stackoverflow but I couldn’t understand how it is implemented.

Could anyone help me understand how Powershell actually calculate the average from the same column in muliple files ? I want to create a new file with the similar columns; Lat Long and Average.

Thanks

Jdbaba

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:37:16+00:00Added an answer on June 18, 2026 at 6:37 am

    there are surely more efficient ways but here is one :

    $results=@{}
    
    #assuming your files are tab delimited and named position1.csv, position2.csv ...:
    ls c:\temp\position*.csv | foreach
        {
        get-content $_.fullname | foreach
        {
            $slices=$_.split("`t")
            #verify we have our 3 columns
            if( $slices.count -eq 3)
            {
                #create an hash table with latitude-longitude as key
                $key=$slices[0]+"-"+$slices[1]
    
                if( $results.count -ne 0 -and $results.GetEnumerator().name -contains $key ) {
                    $results[$key]+=$slices[2]
                }
                else{
                    $results[$key]=@($slices[2])
                }
            }
        }
    }
    
    $results.GetEnumerator().name |%{
       "{0}`t{1}`t{2}" -f ($_.split("-")[0]) , ($_.split("-")[1]) , ($results[$_] | Measure-Object -Average).Average
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a relatively new Powershell user, and have what I thought was a simple
I have a function like this in Powershell. When the user passes a null
I'm a new user to knockout.js and so far have been very impressed with
I have created a PowerShell script for copying files to a directory, the script,
I have a multi-user Access database which is compacted daily using a powershell script.
I'm a Brand new User to MySQL DB, have installed the WAMPSERVER and I'm
I have setup a new user and roles to the Sitecore domain. The user
I am a new user in Git world. I used to use Subversion (using
I need add a new user group for mediawiki. The new group has more
I am a new user to git and I am starting a new project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.