Needs Pictures: 0
Picture(s) thanks: 0
Results 1 to 15 of 56
Thread: Help with macros and Java
-
26th December 2016, 06:30 PM #1
Help with macros and Java
I'm editing a very large text file in OpenOffice (7,000+ pages, over 420,000 lines) and I've been able to use Search and Replace for a lot of the editing.
However I'm now at the stage that the find part of the equation works but there is no way to do the replace.
What I have to do is search for a particular character which is the first character in a line, for example the number 1.
I then have to go to the end of the line above and hit delete to bring all the text in the lower line into the line above it.
ACROBAT CREEK QLD,Stream,,-26.70000,152.97000
Acron Oval NSW,Reserve,,-33.73000,
151.17000
Acrostic Ridge NSW,Ridge,,-32.54000,150.19000
Actaeon Island Game Reserve TAS,Reserve,,-43.52000,146.99000
This is a database of Australian place names and various locations.
I am reverse engineering the database so that I can add new locations to it and then compile it so it runs on my Hema navigator.
I have recorded the macro, but when I try to run it I get the following message:
"Openoffice requires a Java runtime environment (JRE) to perform this task. Please
insall a JRE and restart OpenOffice"
I downloaded jre-8u65-windows-x64.exe and ran it, I restarted my computer and opened the document in OpenOffice, but I still can't get the macro to run.
Any help would be greatly appreciated.Last edited by Grumpy John; 26th December 2016 at 06:47 PM. Reason: Added additional information
To grow old is inevitable.... To grow up is optional
Confidence, the feeling you have before you fully understand the situation.
What could possibly go wrong.
-
26th December 2016 06:30 PM # ADSGoogle Adsense Advertisement
- Join Date
- Always
- Location
- Advertising world
- Age
- 2010
- Posts
- Many
-
26th December 2016, 07:15 PM #2
If you download Notepad++ or PFE32 the job will be faster. These are pure text editors.
Your find replace strings are "\n1" with " 1"
i.e. replace newline 1 with space 1
It will rip through the file in milliseconds.
-
26th December 2016, 07:20 PM #3
I have Notepad++, but the file is o large it hangs when loading.
Okay, I just tried it again and it opened in a flash. I have reduced the file from 53Meg down to 17Meg, just by removing all the unnecessary spaces.To grow old is inevitable.... To grow up is optional
Confidence, the feeling you have before you fully understand the situation.
What could possibly go wrong.
-
26th December 2016, 07:28 PM #4
So if I wanted to find all instances of N/A and delete the whole line including the return at the end of the line how would I do it?
To grow old is inevitable.... To grow up is optional
Confidence, the feeling you have before you fully understand the situation.
What could possibly go wrong.
-
26th December 2016, 07:31 PM #5
If you need a hand, just ask. I did this as a job processing and munging giant files and stuffing them into databases. Clients would hand us the most aweful crap. Government was the worst. They were utterly, completely and totally clueless.
I often wrote brief programs to handle the really nasty stuff. Often in perl and PHP using grep and such.
-
26th December 2016, 07:33 PM #6
-
26th December 2016, 07:38 PM #7
Thanks Wood Pixel. I actually recorded a macro and played it to the EOF and that did the job.
I've got heaps more to do, so I may have more questions.To grow old is inevitable.... To grow up is optional
Confidence, the feeling you have before you fully understand the situation.
What could possibly go wrong.
-
26th December 2016, 07:41 PM #8
-
26th December 2016, 07:42 PM #9
Notepad++ is an absurdly powerful little program. You can do some very gnarly things with a thing called Regex .... regular expressions.
A quick google on "Notepad++ find and replace" has a few blogs that describe various aspects, but this one seems to cover things off Mark's Speechblog: Notepad++: A guide to using regular expressions and extended search mode
F2 and F3 are your friends. Remember to save incrementally often, it will make it faster, plus give you something to go back to when you explode it.
-
26th December 2016, 07:47 PM #10
Damn it's fast,
Next question:
Find all occurrences of a space at the start of a line. Then cut and paste that line (including space) into the line above.To grow old is inevitable.... To grow up is optional
Confidence, the feeling you have before you fully understand the situation.
What could possibly go wrong.
-
26th December 2016, 07:47 PM #11
Probably not. If you are searching for a specific thing then these might help. For example finding the word "boo" will also find Boo, boogle and booble. These options simply help with either finding or eliminating these finds.
For this stuff it's often a case of "try and see if it works"!!!
Data is generally a mess and there are a billion rules and tricks, but like most things knowing just a few covers 98% of cases. Just remember to save incrementally so you can roll it back. I.e. call the file text2.txt or text3.txt etc.
-
26th December 2016, 07:53 PM #12
Find "\n " replace " "
I.e find newline character then space, replace with just space
One thing to think of when looking at text and how it's laid out is the machine litterally sees it as one single giant line. It is presented to us with line breaks, character returns and other odd characters that may turn up, such as \0x
These are normally invisible. Just prune them as needed.
-
26th December 2016, 08:03 PM #13To grow old is inevitable.... To grow up is optional
Confidence, the feeling you have before you fully understand the situation.
What could possibly go wrong.
-
26th December 2016, 08:13 PM #14
My pleasure to assist. no need for thanks.
You will find there is a hidden character by windows there called \r
It is the Return line character.
Try this: find " \r\n" replace " "
English: find space windowsReturn newline, with just space
Edit: try " \r" replace " " just in case the offending character is only the \r
The link I gave above is very good indeed. I took the time to give it a bit of a read and must say the guy has done a service to the Internet to publish it
-
26th December 2016, 08:43 PM #15
I ended up creating a macro using the "\n " and going to the end of the line above and hitting delete.
Ran the macro till the EOF, worked like a charm.To grow old is inevitable.... To grow up is optional
Confidence, the feeling you have before you fully understand the situation.
What could possibly go wrong.
Similar Threads
-
Micro-Macros
By Ed Reiss in forum PHOTOGRAPHYReplies: 0Last Post: 3rd February 2013, 01:49 PM -
New Macros
By Ed Reiss in forum PHOTOGRAPHYReplies: 4Last Post: 10th November 2011, 08:08 AM