Forum Discussion
Need to convert a text file into a CSV
LainRobertson
I updated the script but I'm still getting the empty row, this is how I'm using it and what I see.
No worries.
I still only have the single-liner you uploaded to OneDrive as the reference export from Payroll to work with, from which I don't get this issue.
Do you possibly have another sample export that produces the issue I can try?
Cheers,
Lain
- Baron164Jun 03, 2022Brass ContributorExcellent, 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.
- LainRobertsonJun 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
- Baron164Jun 03, 2022Brass ContributorYeah, unfortunately I'm stuck with the formatting as is.
- LainRobertsonJun 03, 2022Silver Contributor
Yep, perfect - thanks for that.
What wasn't in the original one-liner that is likely to be causing the issues is the final " xxxx rows selected". row.
That row triggers the error as shown below. I'll see what I can quickly do about that (I'm assuming this isn't something that the export process can't exclude?)
Cheers,
Lain
- Baron164Jun 03, 2022Brass ContributorSure, try this version. It is more accurate to the real file.
https://1drv.ms/t/s!AoktdqajV6ZomugiWnhqPVOEOU6lkA?e=ZKrzZ3