import - PowerShell - How to treat an imported column as a set of numeric digits? -


i have csv looks like:

no,bundleno,grossweight,pieces,tareweight,netweight 1,q9,193700,1614,646,193054 2,q7,206400,1720,688,205712 

what want divide each value in column netweight 25 reason struggling.

here's have code-wise:

$filecontent = import-csv $file $netweight = $filecontent | select netweight $netweight | foreach-object { $_/25 } 

which gives me error:

method invocation failed because [system.management.automation.psobject] not contain method named 'op_division'. 

i have tried several variations attempting convert values numeric value no success.

any appreciated. thanks, john

you have couple of options, problem you're trying operate on property of object.

using current version you'd still need explicitly access netweight property though you've selected it:

$netweight = $filecontent | select netweight $netweight | foreach-object { $_.netweight / 25 } 

alternatively, flatten property when select it:

$netweight = $filecontent | select -expandproperty netweight $netweight | foreach-object { $_/25 } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -