Here is a powershell script where it could "compare and update".
This particular powershell will look for the username and insert it from one file to the other.
* Adjust and use it in your own risk.
$strPath = "C:\s\library.csv" # this is the main spreadsheet which we look for the username and update the password
$strPath2 = "C:\s\Year102016.csv" # this is the csv file which contains the username and password
$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $false
$workbook1 = $objExcel.Workbooks.Open($strPath)
$worksheet1 = $workbook1.sheets.item("library")
$intRowMax1 = ($worksheet1.UsedRange.Rows).count
$workbook2 = $objExcel.Workbooks.Open($strPath2)
$worksheet2 = $workbook2.sheets.item("Year102016")
$intRowMax2 = ($worksheet2.UsedRange.Rows).count
$colA = 1 # column contain the username
$colO = 15 # Where we need to insert the password
#
#
Function checkAndAdd
{
Param($username, $password)
write-host "Second FOR Loop: " $intRow1 " Looking for username: " $username
# Loop from Row 1 to the last Row
for ($intRow1 = 1 ; $intRow1 -le $intRowMax1 ; $intRow1++)
{
# read the username into $colA
$colA = $worksheet1.cells.item($intRow1,1).value2
if ($colA -match $username)
{
Write-Host "Found username: " $username " insert password to column now."
$worksheet1.cells.item($intRow1, $colO) = $password
break
}
} # ROW FOR LOOP
}
# READ the Year102016.csv row by row, pass in the Username, Password, to the other Excel file
# MAIN For Loop
#
Function ReadUsernamePassword
{
# Loop from Row 2 to the last Row
for ($intRow2 = 2; $intRow2 -le $intRowMax2 ; $intRow2++)
{
# Make sure column 1 = username, column 8 = password
$username = $worksheet2.cells.item($intRow2, 1).value2
$password = $worksheet2.cells.item($intRow2, 8).value2
write-host "MAIN For Loop: "$intRow2 " checking username: " $username " password: " $password
checkAndAdd $username $password
}
}
#>
# Check 1 code only
# Beware the strPath file that you read/write to may need to change.
Function Check1Code
{
Param($username, $password)
checkAndAdd $username $password
}
## Uncomment this to Run Check1Code
##
##
#
#Check1Code "abc1234" "password"
ReadUsernamePassword
$workbook1.SaveAs('C:\s\LibraryFINAL.csv') # output file
$objexcel.quit()