Skip to content

Instantly share code, notes, and snippets.

Created Oct 25, 2017
What would you like to do?
# Import CSVs
$csv1 = Import-CSV -Path c:\temp\csv1.csv
$csv2 = Import-CSV -Path c:\temp\csv2.csv
# Loop through each item in csv1
foreach ($item in $csv1) {
$thisDataType = $item.DataType
# find the entry in csv2 where csv2's column name matches this column name
$csv2DataType = ($csv2 |Where-Object {$_."Column Name" -match $item."Column Name"}).DataType
# If the two don't match, say so
if (! $thisDataType -eq $csv2DataType){
Write-Output "CSV2 datatype does not match CSV1 datatype for Column Name $($item.'Column Name')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment