Thanks for the forums, they look active from the great community that’s here.
Problem: I have a text file with some data separated by new lines and spaces that I want some of it converted to csv, so that I can then import into a database.
Sample data:
Tue 09/10/2019 08:20:46:27 Text Here
FOO 8000 - BAR 10.1.0.70 XXX
7,846
$22,037.00
$292.50
We will need a bit more details, you have various entries here and will need to look at a way to filter them into a new PSCustomObject. We also request you to provide the code you currently have worked on. This forum is not here to build the code for you, but instead on your journey to learning of PowerShell and its awesomeness! I’m happy to help with the coding, but your efforts are required first.
PSCustomObject is used to create a custom object that you can add the note properties (members) and then pipeline to other cmdlets. You would still need to look at adding filtering to your data. If you can provide a subset of data that we can use that will help to provide you with more guidance.
Example below note this uses Powershell 4.0 or higher.
As you see in the original post, the file is five lines, with each value separated by a space or a new line. The second line contains FOO and BAR, separated by a - and spaces.
Does this help?
Edit: Sorry, I don't know how to hide the white spaces or red marks.
Assumed your input text file always has the same format and with the requirement to create the output you stated in your first post you will probably have to parse it yourself. This comes close … if I got it right: