Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Merge multiple CSV files with a join on the Name column and rename other columns to filename

$
0
0

Hey guys can anyone help me with this, I need a Powershell script to join multiple csv files together but am getting nowhere with it.

Basically I have multiple csv files which all have a Name column a Version column and several other columns which I am not interested in.

Name    Version  Field3  Field4  etc

---------------------------------------

Model1  1.1.3    na        na      na

Model2  1.1.2    na        na      na

Model4  1.1.2    na        na      na

Model6  1.1.3    na        na      na

Model7  1.1.4    na        na      na

The Names in the Name column will match in each csv, but some may have extra or less.

What I need is a script which will list all Names from each csv file with no duplicates and have a separate column for each csv file called the same name as the csv file name it came from and listing the version numbers for each model, some will be empty.

ie

Name  FileName1  FileName2  FileName3

---------------------------------------------

Model1  1.1.3        1.1.3           1.1.4

Model2  1.1.2        1.1.2           1.1.3

Model3  1.1.2                          1.1.2

Model4  1.1.3        1.1.3           1.1.4

Model5  1.1.4        1.14 

etc....

    

and to then save this as a new csv file.

any help on this would be great.



Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>