{"id":2772,"date":"2013-10-04T00:01:00","date_gmt":"2013-10-04T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/10\/04\/csv-add-a-carriage-return-for-powershell-import\/"},"modified":"2013-10-04T00:01:00","modified_gmt":"2013-10-04T00:01:00","slug":"csv-add-a-carriage-return-for-powershell-import","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/csv-add-a-carriage-return-for-powershell-import\/","title":{"rendered":"CSV: Add a Carriage Return for PowerShell Import"},"content":{"rendered":"<p><strong>Summary<\/strong>: Guest blogger, Tim Bolton, talks about modifying a .csv file to promote cleaner import.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. Today we have the first of two posts by guest blogger, Tim Bolton. This one feeds into his post that will be published on Monday, but the idea is a standalone. Take it away, Tim&hellip;<\/p>\n<p>When I set up new conference rooms, I was requested to list the items that are available in the room&nbsp;within the Notes section of Exchange Server, for example:<\/p>\n<p style=\"padding-left: 30px\">Seating: 12,&nbsp;Ceiling Projector: YES,&nbsp;Projection Screen: YES,&nbsp;White Board: NO,&nbsp;TV: NO<\/p>\n<p>When I created these accounts with a .csv file imported into Windows PowerShell, I inserted them as a line entry. Like the previous example, this resulted in:<\/p>\n<p style=\"padding-left: 30px\">Seating: 12, Ceiling Projector: YES, Projection Screen: YES, White Board: NO, TV: NO<\/p>\n<p>This was causing confusion when users were using Outlook&nbsp;2010 to&nbsp;search for available items in the conference rooms. I was asked to &ldquo;stack them,&rdquo; meaning stack each item instead of using a single, comma-separated line.<\/p>\n<p>They were stacked in the .csv file; however, the carriage return was not passing during the import from the .csv file to Windows PowerShell. This is shown in the image that follows.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0755.hsg-10-4-13-1.png\"><img decoding=\"async\" title=\"Image of items\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0755.hsg-10-4-13-1.png\" alt=\"Image of items\" \/><\/a><\/p>\n<p>Here is my fix&hellip;<\/p>\n<p>In Excel, prior to saving as a .csv file:<\/p>\n<p>1) Highlight the entire column for the stacked info.<\/p>\n<p>2) Click <strong>Find and Replace<\/strong>, and then click&nbsp;<strong>Replace<\/strong>.<\/p>\n<p>3) In the <strong>Find what:<\/strong> text box: &nbsp;<br \/> Enable <strong>Num Lock<\/strong>. Press the <strong>ALT<\/strong> key, and then use the number pad to type the numbers <strong>010<\/strong>. (I got this numeric value from my brilliant coworker, Chris Duck.) It will not show up when you type it, which is normal.<\/p>\n<p><strong>Note<\/strong>&nbsp;&nbsp;It is important to use the number pad because the numbers that run across the top of your keyboard may have an alternate task; and therefore, the ASCII key code for the carriage return\/line feed may not register properly.<\/p>\n<p>&nbsp;(If you are using a laptop without a number pad, you should be able to press the <strong>Fn<\/strong> + <strong>ScrLk<\/strong> keys to enable Num Lock for the alternate number pad in the middle of your keyboard, if your laptop supports this feature.)<\/p>\n<p>4) In the <strong>Replace with:<\/strong> text box, type a single semicolon (&nbsp;<strong>;<\/strong> ), as shown in the following image:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0842.semicolon.png\"><img decoding=\"async\" title=\"Image of text box\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0842.semicolon.png\" alt=\"Image of text box\" \/><\/a><\/p>\n<p>5) Click <strong>Replace All<\/strong>. The modified fields now appear as shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7384.hsg-10-4-13-3.png\"><img decoding=\"async\" title=\"Image of list\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7384.hsg-10-4-13-3.png\" alt=\"Image of list\" \/><\/a><\/p>\n<p>6) Now save the file as a .csv file. When you import the file to Windows PowerShell, it will stack them because it now sees the semicolon (&nbsp;<strong>;<\/strong>&nbsp;) as a carriage return, which Windows PowerShell will understand.<\/p>\n<p>Now when you view the conference room through either Outlook&nbsp;2010 or Exchange Server, the information will be &ldquo;stacked,&rdquo; as shown in the following example:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0702.hsg-10-4-13-4.png\"><img decoding=\"async\" title=\"Image of menu\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/0702.hsg-10-4-13-4.png\" alt=\"Image of menu\" \/><\/a><\/p>\n<p>Cool, right?<\/p>\n<p>~Tim<\/p>\n<p>Thank you, Tim, for an excellent post. Join me tomorrow when I will talk about more cool Windows PowerShell stuff.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><strong>Ed Wilson, Microsoft Scripting Guy<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Guest blogger, Tim Bolton, talks about modifying a .csv file to promote cleaner import. Microsoft Scripting Guy, Ed Wilson, is here. Today we have the first of two posts by guest blogger, Tim Bolton. This one feeds into his post that will be published on Monday, but the idea is a standalone. Take it [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[455,56,3,324,45],"class_list":["post-2772","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-csv","tag-guest-blogger","tag-scripting-guy","tag-tim-bolton","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Guest blogger, Tim Bolton, talks about modifying a .csv file to promote cleaner import. Microsoft Scripting Guy, Ed Wilson, is here. Today we have the first of two posts by guest blogger, Tim Bolton. This one feeds into his post that will be published on Monday, but the idea is a standalone. Take it [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2772","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=2772"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2772\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=2772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}