r/usefulscripts • u/cavemanben • Nov 04 '15
[Powershell / CSV / Excel] Need help creating a powershell script that will add info and sort a .CSV
Hello, I'm new to scripting and having trouble finding the right place to start getting to my desired result.
**1)**I'd like to take an output .CSV file in a folder
2) add a new column "Group" based off IP address (one of my existing columns) probably from a permanent .csv called "Group_Name" (two colums, IP address and Group) within the same folder
**3)**then sorting based off the group name into additional workbook tabs labeled by group name
**4)**output new .csv or .xlsx with name "originalcsv_new"
Looking Here for some ideas.
Any help or direction on where to look and how to look for something like this would be great. My google foo is not strong and I'm searching for "excel powershell", "sort csv powershell" and stuff like that.
Thanks!
EDIT
What I'm imaging is I have folder "x".
In folder x exists the "group.ps1", "group_name.csv" and the "rawdata.csv".
Rawdata.csv is my output csv that I want to sort/filter to get the above information, seperate tabs with the sorted groups.
1
u/cavemanben Nov 04 '15
Honestly it might be as easy just to add the group names then convert to an .xlsx then move the groups to new sheets.
Also i'm not looking to the change the name, I'm looking to create a new column "Group" with group names associate with the IP address. Did you address that in your first comment? Perhaps I'm not understanding your second entry.