Learn about Windows PowerShell
Summary: Here is Problem 2 in Windows PowerShell Mini-Scripting Games 2014.
Microsoft Scripting Guy, Ed Wilson, is here. It is time for the second problem of the Windows PowerShell Mini-Scripting Games. Remember: Please do not post any answers to these problems until next week. Please do not spoil the fun for your fellow scripters!
You have a CSV file that contains five columns. It comes from the HR department and it contains information that you do not need. You only need to work with three of the columns.
Hint: Create a very simple CSV file by using Notepad (or another feature), and save it. The file should contain five columns and several rows of sample data. Keep it simple. The columns CAN be named a, b, c, d, e. Then write code that will read this CSV file, and create an object that contains only three columns from the file. Now save that as a CSV file.
Mini-Scripting Games Week will continue tomorrow when I will reveal Question 3 (PowerTip) and Problem 3.
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at email@example.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy
I'm guessing it'll fit on 1 punched card.
@COBOL Programmer My mom was a key punch programmer, and I remember seeing the trays of cards. I can tell you for a fact, that it will NOT fit on a single key punch card :-) Hope you have fun with the event.
I think there is a word missing for task 1.
I Guess you meant "Create a custom object that contains only THREE columns."
Wow! This is a very useful page and I really enjoyed reading article and all users’ comments. Looking for some of the best board games?! Look no further because we have all the best board games rated for you for any special occasions.
Two steps per the requirments....
$tooManyColumns = Import-CSV "C:\Test\Test.csv" | Select a,d,e
$tooManyColumns | Export-CSV C:\test\new.csv
or the one-liner:
Import-CSV "C:\Test\Test.csv" | Select a,d,e | Export-CSV C:\test\new.csv