Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Converting csv from a txt file

$
0
0

Hi,

There is a txt file, I have updated which I need to convert to a csv file. The txt file looks something like this.

Count,Test                                                           Number    
----------------------------------------------------------------- ----------    
46,003201                                                                  3    
14,008131                                                                  2    
8,003150                                                                   1    

I am running this piece of script 

Import-Csv C:\VPS\newfile.txt |
Where-Object {$_.Count -notmatch '----'} |
export-csv C:\VPS\newfile3.csv -notype


However the output does not seem to work. This is what I get.There are spaces as you see below.

"Count","Test                                                                                         Number    "

"46","003201                                                                  3   "
"14","008131                                                                  2   "
"8","003150                                                                   1    "

I am trying to create a csv file with the correct format. This is what I am expecting.

"Count","Test ",  "Number"

"46","003201" ,"3"
"14","008131","2"
"8","003150","1"

Please assist.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>