I have problem with data in the file. Data in the text file looks like:
ADSE64E...Mobile phone.....................
EDW8......Unknown item.....................
CAR12.....Peugeot 206 with red colour......
GJ........Parker model 2...................
Por887W8..Black coffe from Peru............
The dots represents blank spaces. First column is Product_Code (long 1-10) and second (long 1-255) is Description. All i need is:
ADSE64E;Mobile phone
EDW8;Unknown item
CAR12;Peugeot 206 with red colour
GJ;Parker model 2.
Por887W8;Black coffe from Peru
My solusions are:
-
First column get to the variable (and same process with second column) and merge both variables to one.. But i dont know how..
$variabletxt = get-content C:\Product.txt
$firstcolumn = $variablestxt.substring(1,10)
$secondcolumn = $variablestxt.substring(10)
$final = ???
-
Replace blank spaces but problem is that product_code may by long 1-10.
Have you any suggestion how I resolve this problem?
split your sting then replace “more than one space” with nothing :