Forum Discussion
Baron164
Mar 21, 2022Brass Contributor
Need to convert a text file into a CSV
I have a text file from payroll that includes all active employees and their relevant information such as Phone Number, Office Location etc. I need to convert this file into a CSV so I can more easil...
LainRobertson
Jun 03, 2022Silver Contributor
All good - I figured as much.
Here's the new line 55. Just remember to either unload the existing psm1 from memory using "Remove-Module EmployeeData" or close the PowerShell session in which you've loaded it and open a new one. Otherwise, the change won't be acknowledged in a session where the .psm1 has already been loaded.
It's not a brilliant solution, but it'll do in this case - and I didn't have to think much to do it quickly.
if ($_.Length -gt 0 -and -not [string]::IsNullOrWhiteSpace($_.Replace(",", "")) -and $_.IndexOf("rows sel", [System.StringComparison]::OrdinalIgnoreCase) -eq -1)
Cheers,
Lain
Baron164
Jun 03, 2022Brass Contributor
Excellent, thank you. The new csv does not have the empty row and the import process completes cleanly without errors. Running the conversion still throws exceptions but it's working so I can deal with that.