Powershell script to split up .csv file


The PowerShell script posted here by Jose Barreto can be used to split up a large .csv file that is difficult to open in Excel.

In this example we have a .csv file which has dates in the first column.

Enter the following script in PowerShell, listing the path of the source file [C:\FooFolder\2019.12.04\Book1.csv]; the date to split by [gt [datetime] "02/15/2010"]; and then the output file [C:\FooFolder\2019.12.04\Book1split2.csv]

$l=0; type C:\FooFolder\2019.12.04\Book1.csv | ? { ($l++ -eq 0) -or ([datetime] $_.Split(",")[0] -gt [datetime] "02/15/2010") } | Out-File C:\FooFolder\2019.12.04\Book1split2.csv -Encoding utf8

A new file will be generated that contains only the data from the first, with the entries after 2/15/2010 in the first column.


Contact Me With Your Litigation Support Questions:

seankevinoshea@hotmail.com

  • Twitter Long Shadow

© 2015 by Sean O'Shea . Proudly created with Wix.com