This blog has moved to http://ThePowerShellGuy.com
Greetings /\/\o\/\/
When I did see todays Hey, Scripting Guy! question (and more answer)
Hey, Scripting Guy!
How Can I Query a Text File and Retrieve Records That Occurred on a Specific Date?I could not resist :
Hey, PowerShelled Scripting Guy!import-csv employees.txt |? {$_.HireDate -eq '3/1/2006'}but to be honest I also use ADO a lot with CSV files from PowerShell, but mostly with a Dataset and a DataAdapter,
# with import-csv function
MowPS>import-csv employees.txt |? {$_.HireDate -eq '3/1/2006'}
LastName FirstName Department HireDate
-------- --------- ---------- --------
Myer Ken Finance 3/1/2006
Ackerman Pilar Finance 3/1/2006
# With ADO (and 2 helper functions)
MowPS>. connect-csv (pwd)
TABLE_NAME
----------
Employees#txt
MowPS>(get-DataTable "Employees#txt") |? {$_.HireDate -eq '3/1/2006'}
LastName FirstName Department HireDate
-------- --------- ---------- --------
Myer Ken Finance 3/1/2006 12:00:00 AM
Ackerman Pilar Finance 3/1/2006 12:00:00 AM
in this case you see that it does not matter much, and for the ADO example I need 2 helper functions and it is outputting more or less doing the same, but in the second example I have the power of the .NET dataset and can make relations etc
for more info and the helper functions see :
working with CSV files in MSH (part one)working with CSV files in MSH (part two)And without the dataAdapter and dataset :
more Monad scripts, and a bit more CSVenjoy,
gr /\/\o\/\/
Tags : Monad msh PowerShell