Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Need convert txt to csv using Powershell

$
0
0

Hello,

I'm trying to read txt file:

==================================================
URL               : about:blank
Title             : 
Visit Time        : 06.10.2014 8:43:03
Visit Count       : 5354
Visited From      : 
Web Browser       : Internet Explorer 10
User Profile      : User
==================================================

==================================================
URL               : file:///C:/
Title             : 
Visit Time        : 15.03.2013 10:32:03
Visit Count       : 1
Visited From      : 
Web Browser       : Internet Explorer 10
User Profile      : User
==================================================

==================================================
URL               : http://xx
Title             : 518 
Visit Time        : 30.07.2014 15:16:28
Visit Count       : 1
Visited From      : http://xx.xxxxx.xx/adv_out?Id=68265&direct=1
Web Browser       : Chrome
User Profile      : User
==================================================

I need output:

URL, Visit time,

about:blank, 06.10.2014 8:43:03,

file:///C:/, 15.03.2013 10:32:03

http://xx, 30.07.2014 15:16:28

thank you very much for help

this i'm trying to use, but i get one line

$lines = Get-Content "1.txt"

ForEach ($Line in $lines)
{
if ((($Line.contains("URL")) -or
 ($Line.contains("Visit Time"))))
 {
 $Object += $Line + " , "
 }
 }
$Object | out-file 1_out.txt



Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

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