Solved

How to add extra line into a CSV

Posted on 2013-06-17
4
425 Views
Last Modified: 2013-06-17
Hello, i am trying to build a CSV with the following:
$date = Get-Date
$Out0 = "---------------VMware Health vCenter2---------------"
$Out1 = "---------------------Date and Time---------------------"
$Out2 = "--------------------" + $date + "----------------------"

Open in new window

But would like to add an space or extra line below of Out2.
Thanks for your help,
0
Comment
Question by:namerg
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39254668
If you are using Add-Content to construct the CSV, then you can try something like..
$file = "C:\temp.csv"
$date = Get-Date
$Out0 = "---------------VMware Health vCenter2---------------`n---------------------Date and Time---------------------`n--------------------" + $date + "----------------------"
Add-Content $file $date                                  
Add-Content $file $Out0
Add-Content $file ""
Add-Content $file "Data Here"

Open in new window

0
 

Author Comment

by:namerg
ID: 39254696
Yep...
Question:
What is the difference between the `n and Add-Content $file "" ?
0
 

Author Comment

by:namerg
ID: 39254715
Hmm, it looks the same thing..right ?
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39254736
`n - is for a new line in PowerShell
If you run Add-Content $file "`n" then it will write "" in a new line (means you get two empty lines before you write "Data Here")


Add-Content $file $Out0
Add-Content $file ""
Add-Content $file "Data Here"


and

Add-Content $file $Out0
Add-Content $file "`nData Here"

Will give the same result..
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question