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 7694489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:19:56+00:00 2026-05-31T21:19:56+00:00

I have an input CSV file with a column containing information similar to the

  • 0

I have an input CSV file with a column containing information similar to the sample below:

805265
995874
805674
984654
332574
339852

I’d like to extract unique values into a array based on the leading two characters, so using the above sample my result would be:

80, 99, 98, 33

How might I achieve this using PowerShell?

  • 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-05-31T21:19:57+00:00Added an answer on May 31, 2026 at 9:19 pm

    I’d use the Group-Object cmdlet (alias group) for this:

    Import-Csv foo.csv | group {$_.ColumnName.Substring(0, 2)}
    
    Count Name                      Group
    ----- ----                      -----
        2 80                        {805265, 805674}
        1 99                        {995874}
        1 98                        {984654}
        2 33                        {332574, 339852}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have imported a csv file containing spatial area information in varchar, then converted
I have a CSV (comma separated values) file that contains student information. The column
I have a web page where it will input an excel/CSV file from the
I have two .csv files containing correlation matrices exported from R. One file contains
I have written a program which reads input from csv file and its working
I have csv input file, lets call it heights.csv . my example file has
I have a .csv file containing 3 columns of data. I need to create
I get an input CSV file that I have to upload to my oracle
i have an input csv file with columns position_Id, Asofdate, etc which has to
I have saved input from a textarea element to a TEXT column in MySQL.

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.