I'm stuck in the following situation: I have to get information out of a csv file. I imported the csv using import-csv. My raw data looks like this:
45227;01.10.2018 03:24:00;Xxxx Xxxx Xxxxx x XX xxxxxxxxxxxxxx Xxxxx xxxxxxxxxxxxxxxxxxxxx;;3;XXXX;XXXX;XXX@XX.com;;;3.7;;
Whereas the "3.7"-Line contains my important information ("Points"). Here comes my first problem --> Using import-csv, powershell will save this information in a "string" property. To avoid that i used the following line:
| Select @{Name="Points";Expression={[decimal]$_.Points}}
Now i'm having my Selected.System.Management.Automation.PSCustomObject containing that property System.Decimal. Now i wanted to sum up all the points, that were used by the same e-mail address:
$Data[$Index].Points += ($Imported_CSV | where {$_.Sender -eq $Imported_CSV_Unique.Sender} | measure Points -sum).Sum
This seemed to work just fine, but if i open up $Data[$Index] | gmi'm getting this: Points
NoteProperty double Points=71301.6000000006
It seems like i'm producing an overflow of "double", because the number being displayed is totally wrong. I want to stick to decimal or integer so
i have an output like 71123.4 or something like that.
The property changed to "double". I digged a bit and i found out that Powershell's GenericMeasureInfo.Sum
Property
can only give back a "Nullable
<Double>
"as property value.
Is there any other approach for that, so i don't have to use (Measure-Object -sum).Sum?
Thanks in advance!