I am working on a script which creates a Data.DataTable
with the data from a .csv file. Everything worked fine, I have it in my database with the right values. But to help my database performance I would like to set the data types for the columns of the Data.DataTable
. Unfortunately all my values are converted to strings from the CSV to the Data.DataTable
columns.
My CSV looks like this (example):
"Name";"UserID";"Salary"
"Peter";"1";"1200.03"
"Jennifer";"2";"1000.50"
I tried following methods:
foreach ($object in $csv){
Write-Output "line $countline"
foreach($property in $object.PsObject.get_properties())
{
$property.TypeNameOfValue = [System.Type]::'System.Int32'
***and the other try***
$property.Value = [System.Type]::'System.Int32'
}
}
Both times nothing happened (except errors).
So I want the following to happen: The first column should be a datatype of string ("name"). The others should be double or float.
Does anyone have a solution for this?