Skip to main content

Powershell Commands useful for large CSV files


1) To get the header line, ie: first row in a CSV file 


gc .\FILENAME.csv -TotalCount 1

2) To get the header line, and export it to another CSV file.  Note the use of Set-Content rather than Export-CSV


gc .\FILENAME.csv -TotalCount 1 | Set-Content .\header-file-name.csv

3) To filter the CSV file based on a regex search , and export the matches to another file.


gc .\FILENAME.csv | Select-String -Pattern ( '.*2018-11-20.*' ) | Set-Content .\inner-file-name.csv
4) To see the last few lines, like tail 

gc .\20181206_InteractionDetails.csv | select -last 10

Comments

Popular posts from this blog

Javascript Form Validation

It's real simple. All you need to do is call a javascript function in a html  " onsubmit " in the form tag as a javascript return, like this       <form method="post" action="dosomething.php" onsubmit="return validateForm();"> If the code completes ok, the form is then sent to the page listed in "action" http://www.w3schools.com/js/js_form_validation.asp If the function specified in the onsubmit returns false, then the form is not sent to the page mentioned in action.