Searching and replacing a string
Moderators: AmigoJack, bbadmin, helios, MudGuard
Searching and replacing a string
I am trying to parse a large txt file produced from a PDF.
Unfortunately the PDS 'save as text' system was inconsitent.
Within the file there are strings of random numbers, like:
0 0 0 0 5,107 0 0 -5,107
0 0 0 0 5,277 0 0 -5,277
As you can see, the second row is double spaced which would allow me to insert a field delimiter.
Therefore I need to find a way to find and replace the first sample entering an extra space to make them all consistent.
Does anyone have any ideas?
Unfortunately the PDS 'save as text' system was inconsitent.
Within the file there are strings of random numbers, like:
0 0 0 0 5,107 0 0 -5,107
0 0 0 0 5,277 0 0 -5,277
As you can see, the second row is double spaced which would allow me to insert a field delimiter.
Therefore I need to find a way to find and replace the first sample entering an extra space to make them all consistent.
Does anyone have any ideas?
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Please put text examples in a [/color][/b] block, so that we don't have to examine the source of the page to see what your examples really look like.
Does this do what you need?
Code: Select all
[/color][/b]...[b][color=blue]Does this do what you need?
It assumes you are using Posix regular expression syntax:[Replace the underscores with spaces]
Find what: ([0-9])_(-?)\<
Replace with: \1__\2
[X] Regular expression
Replace All
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
No, unfortunately that doesn't get it; comes up with cannot find regular expression.
Unfortunately these numbers occur in the midle of a line:
NewRecord; AL 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08060333806 05/18/08 0 0 0 0 0 0 0 0 Catastrophe: Claim Status: OP
NewRecord; AL AP 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08050325088 Hernandez, S 05/11/08 0 0 0 0 502 0 0 -502 Catastrophe: Claim Status: CL
Unfortunately these numbers occur in the midle of a line:
NewRecord; AL 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08060333806 05/18/08 0 0 0 0 0 0 0 0 Catastrophe: Claim Status: OP
NewRecord; AL AP 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08050325088 Hernandez, S 05/11/08 0 0 0 0 502 0 0 -502 Catastrophe: Claim Status: CL
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Please use
The regex I gave you most definitely does work on these examples. Make sure there isn't a space at the end of the regex. The replacement produces this:
It has doubled each single space that follows a digit.
Code: Select all
[/color][/b] blocks for your examples (preferably ones with shorter lines), like this:
[code]NewRecord; AL 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08060333806 05/18/08 0 0 0 0 0 0 0 0 Catastrophe: Claim Status: OP
NewRecord; AL AP 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08050325088 Hernandez, S 05/11/08 0 0 0 0 502 0 0 -502 Catastrophe: Claim Status: CL</span><span class="gensmall"></span></td>Code: Select all
NewRecord; AL 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08060333806 05/18/08 0 0 0 0 0 0 0 0 Catastrophe: Claim Status: OP
NewRecord; AL AP 69230 FLEET GROUP PHPL2000097 05/01/08 05/01/09 PHAL08050325088 Hernandez, S 05/11/08 0 0 0 0 502 0 0 -502 Catastrophe: Claim Status: CL</span><span class="gensmall"></span></td>Thank you so much, I did manage to make that work.
How would I pare this into two fields:
How would I pare this into two fields:
Code: Select all
Devenny, B 04/14/09-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
I am so sorry about the delay in in responding:
I believe is what I need is:
That is Name, Initial, Date, where name and initial are Xxxxx, X, and the date is a separate field. (Using ";" as the delimiter.)
I realy have to thank you for your generous assitance; I grew up in the days where fiels where 64 bits, and anrhing after that was deleted.
I believe is what I need is:
Code: Select all
Devenny, B; 04/14/09;I realy have to thank you for your generous assitance; I grew up in the days where fiels where 64 bits, and anrhing after that was deleted.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Thank you Ben, I seriously appreciate your help.
Unfortunately there are about 10,000 lines in this text, it seems 80 percent of it is cruft.
I have now abandoned the project for a couple of reasons:
1: The data input is crap
2: The insurance company behind this don't seem to care, although it seriously affects their profitability.
I am extremely grateful for your input, and really admire your skills in this field.
Again, thank you
John
Unfortunately there are about 10,000 lines in this text, it seems 80 percent of it is cruft.
I have now abandoned the project for a couple of reasons:
1: The data input is crap
2: The insurance company behind this don't seem to care, although it seriously affects their profitability.
I am extremely grateful for your input, and really admire your skills in this field.
Again, thank you
John