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

  • Home
  • SEARCH
  • 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 7935087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:49:02+00:00 2026-06-03T21:49:02+00:00

I am currently importing a CSV file which has a column that is all

  • 0

I am currently importing a CSV file which has a column that is all numbers. I am attempting to cast it as an int and only pull ones that are greater than 100. I have manually gone through this CSV file, and I can confirm that there are three rows with a greater-than-100% value. However, this always returns 0. What am I doing wrong?

$percentTooLarge = Import-Csv path\file.csv | Foreach-Object { $_.SumHoldingPercent = $_.SumHoldingPercent -as [int]; $_ } | Where-Object { $_.SumHoldingPercent -gt 100 } | Measure-Object
$numPercentTooLarge = $percentTooLarge.Count
  • 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-03T21:49:05+00:00Added an answer on June 3, 2026 at 9:49 pm

    Because of the way compare operators work in PowerShell, this should do the trick:

    $percentTooLarge = Import-Csv path\file.csv | 
        Where-Object { 100 -lt $_.SumHoldingPercent} | 
        Measure-Object
    

    Basically, PowerShell, when you compare things, tries to convert right to the type of left. If you put a value from ipcsv first – left will be a string. If you put a numeric first – it will convert the value from the CSV file to a number (it will be smart enough to keep the type big-enough ;))

    I tested with this code:

    @"
    foo,bar,percent
    alfa,beta,120.5
    beta,gamma,99.9
    foo,bar,30.4
    works,cool,120.7
    "@ | ConvertFrom-Csv | where { 100 -lt $_.percent }
    

    … and the results seems OK.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When importing a CSV file into Excel, it only strips the double-quotes from the
I'm importing data from a CSV file that comes from excel, but i can't
When importing numbers from a csv file, I need to convert them to floats
I'm currently importing all of our PHP websites into SVN repositories. Each site has
I am importing a csv file with more then 5,000 records in it. What
I'm currently importing a CSV into an activerecord element but can't choose to parse
went and got a file that already works from here: xls to csv Note,
My project has a bunch of csv files that may or may not be
I am importing a .csv file into MySQL and everything works fine, except the
I have a problem importing a CSV file with RapidMiner. Floating point values are

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.