plistbuddy command value from csv, search and insert
Here's a three-line shell script for bash. Assume the CSV file is named hosts.csv.

h=`hostname -s`
c=`sed -nE -e "/^$h, ?/s/^.+, ?//p" hosts.csv`
/usr/libexec/PlistBuddy -c "Set :2ndfloor:com.apple.print.preset.settings:ManagementCodeValue $c" ~/Library/Preferences/com.apple.print.custompresets.forprinter.CMI2ndFloorColor.plist


The script sets the shell variables $h to the host name, and $c to the code that matches the host. Get the name of the host from the hostname command. Use $c in place of the value "1001" in the PlistBuddy command.

By default the hostname command returns domain information. Therefore if the CSV file has host names without domain information, use h=`hostname -s`, otherwise use h=`hostname`.

The sed command matches a line from the CSV file that starts with the $h host name followed by a comma and an optional space character. For the line that matches, sed removes everything but the code from the line.