Jump to content











Photo
- - - - -

ROTFL - Replacement Of Text Files


  • Please log in to reply
5 replies to this topic

#1 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 22 December 2011 - 06:36 PM

Posted Image

File Name: ROTFL - Replacement Of Text Files
File Submitter: Nuno Brito
File Submitted: 22 Dec 2011
File Updated: 22 Dec 2011
File Category: Tools

This command line tool replaces a given text sequence with another.


Why this tool?
After this forum was upgraded, a lot of the forum posts were not displayed correctly as before. Therefore it was needed to change the SQL file to bring back the original characters. Many people posted solutions to this matter, however our database is large and it was necessary a tool that could do these replacements with a low memory foot print.

It was possible to use SED under Linux but the result was not comfortable and still a lot of manual labor was involved. So, it was an interesting exercise to code a tool for this task.


What distinguishes this tool from others?
  • Based on Java, works on Windows, OSX and Linux when Java is installed
  • Accepts a list of words to replace (edit settings.txt)
  • Is prepared to handle big text files (tested on file of 600Mb in about 30 seconds as seen on screenshot)

To run from Windows
rotfl param1 param2


To run from Linux or OSX
java -jar rotfl.exe param1 param2


Required parameters
param1 is the source file
param2 is the output file

Customizing the settings
To change the list of replaced characters, just edit settings.txt to match your preference.

Click here to download this file

#2 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 22 December 2011 - 06:50 PM

Do you plan to use it to fix globally character problems in old forum posts' CODE wrapped text areas?

#3 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 22 December 2011 - 07:00 PM

Yep, that is the plan.

I set this afternoon aside to solve this problem for good. I started by manually doing the changes and trying out but something was not going as intended and the changes were not reflected on the database.

Now I coded a tool to make these changes automatic and test them on my own desktop machine. I am sure that the tool is capable of doing its work, however I still see no changes after applying the conversion on our exported database and importing it back to the forum.

Might still take a bit longer to get this sorted.

#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 22 December 2011 - 07:55 PM

Using gsar was too simple and old fashioned I suppose. :unsure: and using MySQL Replace() function too obvious....
http://www.lancelhof...ch-and-replace/

It's strange that the reimported database doesn't work, though. :dubbio:

If I may, won't it be advisable to do a few tests on a "fake" board copy before doing it on the "real" one?

:cheers:
Wonko

#5 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 22 December 2011 - 08:16 PM

Plenty of solutions available, pick your weapon of choice. I preferred this one and shared the tool with the community.


If I may, won't it be advisable to do a few tests on a "fake" board copy before doing it on the "real" one?

As it was mentioned before, I did the tests on my own board off line. Don't know yet why it hasn't worked on the production database. I'm out of time for today, will work on this matter later.

#6 AceInfinity

AceInfinity

    Frequent Member

  • Team Reboot
  • 228 posts
  • Location:Canada
  • Interests:Windows Security, Programming, Customizing & Crash Dump Analysis.
  •  
    Canada

Posted 24 December 2011 - 08:36 AM

Pretty nice Nuno Brito, it may come in handy sometime for me, i've downloaded this to check it out
  • Brito likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users