Saving Data: Export-Csv and Cleaning a CSV
Export-Csv saves objects as a CSV file that Excel and other programs open as a table, and on the way there a pipeline can clean an untidy export, dropping its blank rows, renaming its columns and turning text such as $36.00 into numbers with [decimal] and [int].
Journeyman · PowerShell · Operating System · Updated
After this lesson you can
- Save objects as a CSV file with Export-Csv, and open it in Excel
- Clean a CSV export by turning text into numbers with [decimal] or [int], renaming columns and dropping blank rows
Key takeaways
[decimal]'36.00'turns text into a number that's right for money, and[int]'3'into a whole number. A$sign has to come out first, with.Replace('