0

I can't seem to get $d1 and $d2 to print together. Would like to include all columns in one output. (UID, HDate, Email and Office)

$txt1 = "C:\Users\Alex\Downloads\New folder\datafile01.txt"
$txt2 = "C:\Users\Alex\Downloads\New folder\datafile02.txt"
$newtxt = "C:\Users\Alex\Downloads\New folder\new.txt"



$d1 = Import-Csv $txt1 -Delimiter `t -Header "UID", "HDate"| Select-Object -Property *
$d2 = Import-Csv $txt2 -Delimiter `t -Header "UID", "Email", "Office" | Select-Object -Property "Email", "Office"

#$d1
$d2

Can't figure out how to output d1 + d2 together, like concatenate them but while keeping their respective columns. enter image description here

  • Please edit your quston with more info regarding the source `.csv`s. Do they have heders? If so, you don't want the `-header` parameter specified. Are you wanting to combine date based on the `UID`? – Keith Miller Dec 31 '22 at 04:24
  • ...and are you sure both files match on UID for every line in the files? – Keith Miller Dec 31 '22 at 04:25
  • Do both csvs have the same UID? – Abraham Zinala Dec 31 '22 at 05:24
  • Hello, yes both files have the same UID. I will post the requirements for more clarity. – CuriousCoder Dec 31 '22 at 06:32
  • Gonna hit the sack for now, will wake up and continue trying tomorrow. Thanks for any help provided. – CuriousCoder Dec 31 '22 at 06:36
  • [`Join-Object script`](https://www.powershellgallery.com/packages/Join)/[`Join-Object Module`](https://www.powershellgallery.com/packages/JoinModule) (see also: [In Powershell, what's the best way to join two tables into one?](https://stackoverflow.com/a/45483110/1701026)): `Import-Csv .\datafile01.Csv |Join (Import-Csv .\datafile02.Csv) -on uid |Export-Csv .\new.Csv` – iRon Dec 31 '22 at 08:27

0 Answers0