hi friends,
I have the document in which the text appears continously as we see in the notepad. I want to split this long text into the fixed width of text lines so that the document looks nicely formatted. How can I do this with the Powershell ?
hi friends,
I have the document in which the text appears continously as we see in the notepad. I want to split this long text into the fixed width of text lines so that the document looks nicely formatted. How can I do this with the Powershell ?
Try this:
get-content longfile.txt | select-string 2003 | out-file outfile.txt -width _____.
In the blank space, specify the lower value say 150 or 200 so that the next line of the document starts after every that(value) number of characters.
Go to the following link and get all the necessary details and information about splitting the file content into words.
Click here.
One of the important factors is to remove the excess spaces. If the source data is really fixed-width, you should really remove the spaces only AFTER you’ve parsed the line.
you can use a regex split on one or more spaces- [regex] :: Split($s, ” +”)
This is fixed with data, hence it would be safer to select by substring and then trim the excess spaces.
Bookmarks