Log in

View Full Version : Resolved Processing Text File



marain
06-26-2013, 09:58 PM
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
<br /><br />. There MUST be a way to do this other than by brute force.

Suggestions?

A.

traq
06-26-2013, 10:10 PM
most text editors have a find->replace feature.

Beverleyh
06-26-2013, 10:19 PM
I had to do something very similar recently and this is the way I did it. http://uk.answers.yahoo.com/question/index?qid=20070929072105AAjHDWu

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/15740853/replace-new-lines-with-a-comma-delimiter-with-notepad

Hope that helps

marain
06-27-2013, 12:42 AM
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.

traq
06-27-2013, 03:37 AM
gedit (https://projects.gnome.org/gedit/) is a free, cross-platform text editor (similar to notepad) that can do it.

james438
06-27-2013, 04:04 AM
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?

molendijk
06-27-2013, 11:11 AM
Suppose you have a text file like this one:

aaa

bbb

ccc

ddd

Copy the whole text file to the clipboard, then put the result in a converter like this one (http://mesdomaines.nu/eendracht/converters/converter_arie.html).
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.

marain
06-27-2013, 02:28 PM
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.

james438
06-27-2013, 03:50 PM
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.

marain
06-27-2013, 04:58 PM
I've oft' wondered how to mark an issue "resolved." Thank you for the method!

A.