Powershell - CSV Column Manipulation
If you want to change a csv file, there might be easier ways than open it in excel and edit / remove the columns that you dont need.
In this example. I had to extract all the Latitude and Longitude from earthquackes the past month. This was a somewhat 10 000 line long file. So why not try it in Powershell.
Headers looked like this
What i need is "Import-CSV" - Lets do a help on that module.
We want to import Col 1 - 3 with delimiter ",". Then do a foreach-object to print it out again. See below, how i did it.
In this example. I had to extract all the Latitude and Longitude from earthquackes the past month. This was a somewhat 10 000 line long file. So why not try it in Powershell.
Headers looked like this
time,latitude,longitude,depth,mag,magType,nst,gap,dmin,rms,net,id,updated,place,type
What i need is "Import-CSV" - Lets do a help on that module.
We want to import Col 1 - 3 with delimiter ",". Then do a foreach-object to print it out again. See below, how i did it.
Import-Csv .\all_month.csv -Header col1,col2,col3 -Delimiter ',' | Foreach-Object { "{0},{1},{2}" -f $_.col1,$_.col2,$_.col3} | Out-File .\epicenter.txt