Results 1 to 7 of 7
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Delete blank line in text file (2000)

    You could open the text file in Excel, run a macro to delete the rows that you want, then save as a text file again.

  2. #2
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    (resolved) Delete blank line in text file (2000)

    I dont know if is possible...
    Admit have this text file how to loop all line and delete blank line? or delete entire line with condition? for example if left(riga, 3)=abc delete line and up the next

    AAAAAAAAA
    BBBBBBBBBBBB

    CCCC

    BBB




    NNNNNNNNNNNNNNNN

    MMMMMMMMMM

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: (resolved) Delete blank line in text file (20

    Easiest way is to create a small batch file:

    Batch File code

    <pre>@Echo Off

    For /F "tokens=* delims=" % in () Do Echo % >> </pre>


    Place this in a folder saved as clean.bat

    Take your the file (sal21.txt) you want to remove the spaces in and place it in the same folder as the clean.bat file

    in cmd window type navigate to the folder and type:

    clean sal21.txt newsal21.txt

    A new file will be created call newsal21.txt with all the spaces removed
    Jerry

  4. #4
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: (resolved) Delete blank line in text file (20

    hI Jerry very nice tips...
    But is possible to call the bach via vBA code for Excel ???
    I think via shell, command or not?

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: (resolved) Delete blank line in text file (20

    good...
    But assuming i know the dir and the name of source and destination is possible to insert the path in bat or in vba code?

  6. #6
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: (resolved) Delete blank line in text file (20

    <P ID="edit" class=small>(Edited by Jezza on 14-May-08 15:14. To ensure OK after test)</P>Hi Sal

    One of the other Loungers may be able to help or add to this but from memory you could try:

    Create a new batch file called jezza.bat and type in

    clean sal21.txt newsal21.txt


    The in your Excel VBA type

    ...

    Call Shell("c:clean.bat", vbNormalFocus)

    ...

    I have tested this now and it works great
    Jerry

  7. #7
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: (resolved) Delete blank line in text file (20

    Hmmn, I would personally ensure that I knew the location of the directory for the input and output files
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •