Delete consecutive blanks in a string

Hi
I got a csv file that I want to import.
It looks like
user1 Peter Parker
user2 John Doe
The problem is, that there are a lot of blanks between "user1" and "peter" and between "Peter" and "Parker" and so on...
When I run: 
import-csv "C:\userlist.txt" -Delimiter " " -Encoding Default
Powershell treats every blank as a delimiter. Is there a way to delete all blanks and leave just the first blank as a delimiter?

Something like this might work:
((Get-Content C:\userlist.txt) -replace '\s{2,}',' ') | set-content C:\userlist.txt
Import-Csv "C:\userlist.txt" -Delimiter " " -Encoding Default
Boe Prox
Blog |
Twitter
PoshWSUS |
PoshPAIG | PoshChat |
PoshEventUI
PowerShell Deep Dives Book

Similar Messages

  • Find the number of consecutive numeric digits in string

    I am trying to see if a string has say 9 consecutive numeric digits in it but it will only work if the long string of numbers is the first string of numbers.
    e.g.
    This would recongnise the following string (if p_len = 9)
    Tel number 20 20 30 369 for 2nd meeting
         but would not recongnise the following
    For 2nd meeting tel 20 20 30 369
    Could anyone give guidance on how to proceed / a better way of find consecutive numbers in a string?
    Thanks
    Simon
    Code sample -
        LOOP AT TLINETAB.
    Remove blank spaces
          CONDENSE TLINETAB-TDLINE NO-GAPS.
    Find first number and its position *
          IF TLINETAB-TDLINE CA '0123456789'.
            pos = sy-fdpos.
    Does the next x characters contain only numbers?
            IF TLINETAB-TDLINE+pos(p_len) CO '0123456789'.
              append i_report.
            endif.
          ENDIF.
        ENDLOOP.

    Dear Simon,
    you want to check for consecutive numbers in a string. Then you may do the following -
    1. Get all the numbers in the given string into a table in a sequencial order, that is the order in which they appear in the string
    2. Once you have all the numbers you may find out if the numbers are consecutive or not. The following is the code which is not tested
    lv_len = 1.
    lv_pos = 1.
    lv_strlen = strlen ( lv_str ).
    do lv_strlen times.
      lv_alpha = lv_str+lv_pos(lv_len).
      if lv_alpha co '0123456789'.
       append lv_alpha to lt_number.
      endif.
      lv_pos = lv_pos + 1.
    enddo.
    loop at lt_number into ls_number.
      if lv_no is initial.
       lv_no = ls_number.
       lv_no = lv_no + 1.
      else.
       if ls_number eq lv_no and
          lv_consec is initial.
        lv_consec = c_x.
       else.
        clear lv_consec.
       endif.
      endif.
    endloop.
    if lv_consec eq c_x.
    *  !!! string has consecutive numbers
    endif.
    Hope it helps. Thank you.
    Regards,
    kartik

  • How do I delete a blank page and rearrange pages in Pages 5.0?

    I have several blank pages in my document, there is nothing on the page - except the header and footer - and I can't delete the blank pages ... in the previous version you this by selecting the page thumbnail on the left hand side and using the delete key - but this doesn't work ..
    Also you could re-arrange the page order by moving around the thumbnails ... but now this does not work ... so how do I rearrange the pages in a newsletter?
    Please help me ... urgently
    thank you
    Chris

    Apple has removed over 90 features from Pages 5 yjis is one of them.
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5, after Exporting your files to Pages '09, and rate/review it in the App Store, then get back to work.
    Peter

  • IDoc to file - how to delete a blank record at the end of the file.

    Hi,
    My senario is IDoc to file.  I have successfully implemented this using FCC. But when i checked the flat file, it has a blank record at the end of the file( i think PI adds one blank line/record at the end of the file).  Please suggest me What i need to do, to delete the blank record .
    Thanks & regards
    Sreeni

    Kindly Check below.
    Check whether the problem is at mapping level of  adapter level.. to do this count no. of rows/IDOC before mapping and after mapping in IE and no. of rows in the output file.
    Thnx
    Subbu

  • How do I delete a blank section of page?

    Hi,
    I've got a long scrolling page.
    I deleted a large section, which is now blank.
    There more page content afterwards.
    How can I delete a blank section in the middle of my big page?
    (Maybe I can highlight the empty section somehow and just delete it like a word processing doc?)
    Please help!
    Owen L

    Hi Aish,
    Thanks for the reply.
    Clicking didn't give me that box.
    When you say drag the content up from the bottom, is the a way I can highlight all the relevenat content?
    ...Or do I have to hold down shift and highlight everything individually?
    Thanks,
    Owen

  • How Do I delete a blank page from a multiple page doc in Adobe XI?

    How Do I delete a blank page from a multiple page doc in Adobe XI?

    Thank you Claudio.  That's like an ultimate bummer!  So frustrating.  Thank
    you for taking the time to answer my question.
    Best,
    Robert
    Best,
            Robert
    On Sat, Mar 8, 2014 at 10:03 PM, Claudio González

  • How can i delete One Blank Column in my report

    Hi guru's,
    can any one tell me .........
    i'm getting one Blank column in Query output.How can i delete that Blank Column ?
    in the same way Row  Also....
    Thanking  u advancely
    Chandra

    Here is a site with some nice sample code on deleting rows / columns : [http://www.java2s.com/Code/JavaScript/HTML/ModifyingTableColumns.htm|http://www.java2s.com/Code/JavaScript/HTML/ModifyingTableColumns.htm]
    As to where to put the code, edit your web template, then put the code in there. There are script web items that you can use, but be aware that editing javascript in the script item is not too pleasant. I have found the best approach is to rather create the javascript file on my machine, then upload it to the MIME repository, then reference that in the web template.
    Here is how I have referenced the javascript file sitting in our MIME repository:
    < script src="bwmimerep:///sap/bw/mime/Customer/javascript/CustomCalculations.js" />
    I hope this helps you out.
    Cheers,
    Andrew
    Edited by: Andrew Lewis on Jul 18, 2008 9:26 AM

  • Delete 1 blank page in Pages

    Howdy
    I want to delete a page in Pages. It seems to be very difficult to do.
    I have reviewed a lot of the prior posts, and cannot believe that you can't just click on the page that you want to go away, and watch it disappear.
    What I had was a single page, with writing on it. I got to the thumb nail part where I clicked on the dropbox that asked if I wanted to clear all of the contents and just leave an empty page. I clicked yes, the contents disappeared. Now I have a blank page that I want to remove from My Templates.
    When I click on the blank page, I get the same message about clearing all of the contents and leaving the empty page. I tried that a couple of times, nothing changed.
    So I closed out the page, and got a box asking me if I wanted to save the changes. Clicked on that, still got the blank page in My Templates.
    Any suggestions will be appreciated.
    Thank you
    rlmslo

    I am not quite sure what you want. Do you want to delete a custom made template from the " My template " folder?
    Or do you want to delete a blank page of a Pages document?
    The procedure you performed only empties the page. The empty document is still open. If you don't want the document close it, find it in the Finder and throw it in the Bin/Trash.
    If you have opened a copy of a template the template will still exist in the My template folder.
    Which system do you have on your computer?

  • Deleting multiple blank pages.

    Is there any script available to delete multiple blank pages?

    A script can only know if a page contains any words or fields or links or annotations. It can't know if a page contains images or other graphic elements.
    If that's OK with you then yes, you can do it using a script.

  • How to delete excessive spaces for a string??

    like String s="i am a new guy"
    how to make it to "i am a new guy" ??
    i've tried trim() seems it does work for this case
    thanks

    oh......no i typed several spaces symbol between "i"
    and "am" in the first sentence, but this forum seems
    ignore those blank spacesIt doesn't if you use code tags. And it's not the forum, but HTML standard.
    so what i am trying to do is. what if there are say,
    100 spaces between two words in a sentence (string)
    and i want to delete the excessive space and make it
    just one space between two wordsThen trim() doesn't do what you want it to do. As the documentation clearly describes. Use replaceAll.

  • My bookmarks have lost all attached data, and just appear as blank icons. I have tried to delete the blank icons, but it will not let me. I have also tried to type in the website address and re-save it again, but i will nto let me.

    About 70% of my bookmarks now contain no data -- they are blank icons that cannot be deleted. I have tried to type in the web address and save as a new bookmark, but it won't let me -- it just re-saves to the blank icon with no data

    About 70% of my bookmarks now contain no data -- they are blank icons that cannot be deleted. I have tried to type in the web address and save as a new bookmark, but it won't let me -- it just re-saves to the blank icon with no data

  • *Can't delete a blank page.*

    Hello,
    I'm currently on page 30 of a script I'm writing using Adobe Story, but somewhat mysteriously, there appeared an extra blank page between the title page and the first page of the script.  So now I have a blank "page 1" and the script starts on "page 2".  Nothing I've tried has succeeded in removing the page or moving the text up, etc.
    I didn't add the page, so I'm not quite sure how it got there.
    PC - Sony Vaio
    Windows 7
    Adobe Story Build 791
    Additionally, using the "center" justification tool on the title page doesn't quite center it.  It favors the left side just enough to be noticeable to everyone I've asked (to make sure it wasn't my eyes playing tricks).
    Any help is greatly appreciated!
    Take Care,
    Chris

    Thanks for reporting this issue. We will fix this bug in our next update.
    As a workaround, you can remove parentheticals in the following two ways:
    1.       SHIFT TAB
    a.       Hit shift tab, when you are on the parenthetical element type
    2.       Changing the element type
    a.       Click on the line with the parenthetical element
    b.       Change the element type from the top right hand side to action or dialog
    c.       Notice that its gone
    Finally, In the same writing session you can delete the parenthetical by Undo-ing the operation also
    --Anubhav

  • I am not able to delete a blank message in model C...

    When I tried to delete in box messages its being being displaying as "Error occurred, deletion not completed." and its not deleting the received messages because there is one blank message in the list.
    Moderator's Note: The post was edited because the email address was removed. It's not advisable to post any personal information on a public forum.

    The only solution i would recommend is gettin your phone flashed. I had the same problem with a C2-01 i had. Its an internal error that demands for the phone memory to be reinstalled.

  • How do I delete a blank line from an excel spreadsheet

    I am currently using the code below to output an array of strings to an excel template.  I am getting a blank row to appear in between all my data sets.  Any Ideas on how to get rid of it.  I am new to Labview and have had no formal training.  Sorry if the program is poorly written or something just doesn't make any sense. Thanks in advance.
    Code:
    http://www.imagebam.com/image/4fd4cc10167749
    Output File:
    http://www.imagebam.com/image/7e08f110167751

    Mike,
    I tried the probe and didnt see the blank space at the end. I have attached the vi.  I have a set of dynamic data coming in i believe its just 23 numbers and then I am adding a comment in front of that and then appending it to an excel template.  Thanks for the quick responses!
    Attachments:
    Excel_Output.vi ‏100 KB

  • Blank line in string value in insert statement causing problems

    I am generating an sql statement (insert) from an xml document using xsl transformation that is later run in an sqlplus session. The issue I am coming across is that one of the tags contains free-form text that can be any number of lines. Most strings are not causing a problem, but when there is a blank line in the string (two or more endline characters together) sqlplus seems to think this signifies the end of a statement. Here is an example that I hope will clarify what is being created.
    INSERT INTO MYTABLE VALUES('THIS WORKS', 0, NULL, ...);
    INSERT INTO MYTABLE VALUES('THIS
    ALSO
    WORKS', 0, NULL, ...);
    INSERT INTO MYTABLE VALUES('THIS
    DOES NOT
    WORK', 0, NULL, ...);
    Anyone seen this problem before or have a quick fix? All I can come up with is to pre-process the xml document (which, by the way, I have no control over the format as it comes from a client) to compress vertical whitespace. (This seems like overkill to me). Any suggestions would be appreciated.
    Thanks,
    Daniel

    I don't know if this will work for u.
    If ur string has more than one end of lines and u don't need them, u can replace them by a single space using
    replace(string,chr(13)||chr(10),' ').
    If this does not solve ur problem then probably ur srting has a special charachter. To remove it
    take the ascii value of the special character and then see what is the corresponding chr value and then use replace function in ur insert statement where u find this special character.
    I too face same kind of problem and this worked for me.

Maybe you are looking for

  • What's the easiest way to have a message box?

    Hey, i'm making this game and i have one frame and i have and one panel inside, and when the user completes the game i want a message box to popup saying "Congratulations, You Won!" At the moment when the user wins the game, i've just put a "System.o

  • Windows Server 2008 (TS) and Lync Web App installation failure

    Hey folks, I've run into a little big problem due the Lync Web App installation via mstsc on a stand alone Terminal Server 2008 SP2 64 Bit. When I tried to install the Lync Web App Plugin via mstsc and standard user I get the message: "The system adm

  • 8.1 | 11s | Auto-rotate only works for landscape & button does nothing

    The way auto-rotate is sort of doing it's own thing right now. The way it works is if  the screen is upside down (winbutton up) -> tablet mode, rightside up -> laptop mode. Those are the only two switches that it makes, and it doesn't rotate to a por

  • Popup not INSERTing into table and not refreshing called page ...

    Greetings Environment: APEX 3.1.1.00.09 on AIX 5.3 in 10gR2 I have read many of the threads concerning my issue and I feel I am getting close to the answer but somehow have combined too many of the suggestions and am tripping over my own code. Please

  • Running J2ME code in a J2SE VM

    Is it possible to use J2ME classes in J2SE? Could I include some jar with, for example, javax.microedition.lcdui.Image, and use that class in a J2SE program? If so, which jar? thanks, Abraham