powershell - How to read a file and send that data to a csv file? -


I have to read a .dat file (or .txt), just export the first line, and then export this information into a CSV file Does.

Everything is fine, except that it does not send data that I've read, it also sends other things like wrapping or the properties of information.

P> Here I have the code:

  $ a = gate-content C: \ user \ xxxxxx \ document \ batch tutorial \ text.dat -totalcount $ 1 A | Export-csv "C: \ Users \ xxxxxxx \ Documents \ Batchtutorial \ newcsv.csv"   

If I display variable $ then it shows information from the first line of the file when Exports happen when other data or properties of data go in the CSV file instead.

However here is the information that is being generated:

'#' TYPE System.String
PSPath PSParentPath PSChildName PSDrive PSProvider ReadCount Length C: \ Users \ ralcanta \ Documents \ Batchtutorial \ 141005_150210 Re-conceived TravelCurrentPeriod.dat C: \ user \ ralcanta \ Documents \ Batchtutorial 141005_150210 Redesigned Tourism Corruption Pieriod.dat C Microsoft. PowerShell.Core \ FileSystem 1 190

Any help would be appreciated, thanks.

When you assign an object to the export-CSV CMDlet, the properties of the object Output is exported as CSV fields If you want the first line of the input file written in CSV, then you are better by using the out-file cmdlet instead:

  Get-Content 'C: \ your \ input.txt' -ताल नंबर 1 | Out-File 'C: \ your \ output.csv'    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -