Advanced Search

Results 1 to 10 of 10

Thread: Processing Text File

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    130
    Thanks
    49
    Thanked 0 Times in 0 Posts

    Default Processing Text File

    Hi Folks,

    I have a huge text file that I want to convert to .html and upload to my site. Included in the file are hundreds of entries separated by a blank line. Wherever those blank lines exist, I want to insert
    Code:
    <br /><br />
    . There MUST be a way to do this other than by brute force.

    Suggestions?

    A.
    Last edited by marain; 06-27-2013 at 04:57 PM. Reason: To Indicate "Resolved"

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,623
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    most text editors have a find->replace feature.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  3. #3
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,882
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    I had to do something very similar recently and this is the way I did it. http://uk.answers.yahoo.com/question...9072105AAjHDWu

    Shock! Horror! MS Word for web-work? Surely not! Well, normally no, but in my circumstances it worked fine.

    However, I have since discovered a better/safer way to do it in Notepad++ (freebie, plain text editor that you can get from http://notepad-plus-plus.org/ ) and that method is described here http://stackoverflow.com/questions/1...r-with-notepad

    Hope that helps
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  4. The Following User Says Thank You to Beverleyh For This Useful Post:

    marain (06-27-2013)

  5. #4
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    130
    Thanks
    49
    Thanked 0 Times in 0 Posts

    Default

    Traq,

    Did try that approach. The problem with "find" on the software I tried is the software treats what I want to be a hard return argument as a tab, and processes it, essentially, as a find null. But it would make little sense to tell the software to replace null with something else. The software I looked at was notepad, wordpad, and word perfect.

    Bev,

    Thanks, I'll take a look.

    A.

  6. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,623
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    gedit is a free, cross-platform text editor (similar to notepad) that can do it.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  7. The Following User Says Thank You to traq For This Useful Post:

    marain (06-27-2013)

  8. #6
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,681
    Thanks
    78
    Thanked 89 Times in 87 Posts

    Default

    Just curious, but what do you mean by brute force marain?

    Could str_replace or preg_replace be used here, especially if it is only one file?
    To choose the lesser of two evils is still to choose evil. My personal site

  9. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,297
    Thanks
    28
    Thanked 135 Times in 130 Posts
    Blog Entries
    28

    Default

    Suppose you have a text file like this one:
    Code:
    aaa
    
    bbb
    
    ccc
    
    ddd
    Copy the whole text file to the clipboard, then put the result in a converter like this one.
    A click on the convert button will show you the result on the right. In this case, the result will be aaa\n\nbbb\n\nccc\n\nddd.
    Replace the old content of the text file with that string.
    Change the text file into a html file.
    Open the html file using notepad, then replace each occurrence of \n with <br>
    Safe the file. That's all.

  10. The Following User Says Thank You to molendijk For This Useful Post:

    marain (06-27-2013)

  11. #8
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    130
    Thanks
    49
    Thanked 0 Times in 0 Posts

    Default

    OK. Used Word, per suggestion of Beverley, mission accomplished! I had no idea of Word's ability in that regard.

    James438, by "brute force," I meant pasting in the desired code wherever the double line break occurred. Word informed me that it made 1700+ such replacements.

    Thank you, all.

    A.

  12. #9
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    1,681
    Thanks
    78
    Thanked 89 Times in 87 Posts

    Default

    I'm glad you got this resolved. I would encourage you to mark this as resolved as well by editing the first post and then click "go advanced" where you will then see the option to do so.

    Thank you for explaining brute force. I tend to think of brute force as a way to hack passwords. I didn't think that was what you meant here, but was curious if it was the name of another similar type of program.
    To choose the lesser of two evils is still to choose evil. My personal site

  13. #10
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    130
    Thanks
    49
    Thanked 0 Times in 0 Posts

    Default

    I've oft' wondered how to mark an issue "resolved." Thank you for the method!

    A.

Similar Threads

  1. Replies: 2
    Last Post: 12-22-2012, 08:24 PM
  2. Replies: 1
    Last Post: 07-12-2010, 01:31 PM
  3. rich text and form processing question
    By rich1234 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 02-12-2008, 04:16 PM
  4. dynamic text/text file/actionscript
    By chrizzle in forum Flash
    Replies: 8
    Last Post: 06-29-2007, 04:37 PM

Bookmarks

Posting Permissions

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