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

Converting csv file from a txt file

$
0
0

Hi,

I need to create a csv file from a txt file. However it is not working. 

"Count,TestID" | Set-Content C:\VPS\TRH_Report.csv
foreach ($s1 in Get-Content C:\VPS\TRH_Report.txt)
{
        $s1 | Add-Content C:\VPS\temp1.txt
        (gc C:\VPS\temp1.txt) | sc C:\VPS\temp1.txt
        (get-content C:\VPS\temp1.txt) | add-content C:\VPS\TRH_Report_Final.csv
        remove-item C:\VPS\temp1.txt
}
TRH_Report.txt The txt file looks something like this. 

Count,TestID                                                                  

-----------------------------------------------                                 
178,007501                                                                      
84,007350                                                                       
24,004140                                                                       
81,007601                                                                       
21,004120                                                                       
84,003100    


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

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