the problem is that the first field, in the output CSV is the key to the file and when I try to import it I get an error. I am trying to find a way to make the first field numeric and the second field text . FYI.. I have tested the import by removing the Quotes for the first field and I have no problems with the import
I could not figure a way to make that change to my script (below) so, the first field is saved as numeric (without the quotes).
ok, is that also a PowerShell thing, or not?
I think Export-Csv is going to keep messing this up for you. From what I’m seeing, quoting the property values is just baked in.
E.g.
$array = @(
[pscustomobject]@{
ProductID = 1234
name = "stuff"
},
[pscustomobject]@{
ProductID = 321
name = "things"
})
Now I have a quick example array. Piping it directly to ConvertTo-Csv reveals the quotes:
Does your import process require a csv? Could you take the data in PowerShell and use that directly to insert into the database? You should be able to construct a SQL INSERT query using the data from $table.