Hi all,
I have a large text file that I would like to search. In the text there are lots of occurences of the text "P
Hi all,
I have a large text file that I would like to search. In the text there are lots of occurences of the text "P
Hi all,
I have a large text file that I would like to search. In the text there are lots of occurences of the text P
Sorry, what I’m trying to say is:
I have a large text file that I would like to search. In the text there are lots of occurences of the text Panel ID as well as other text, after this text appears there will be a number e.g. Panel ID 80638520 this number changes for each Panel ID. I know that I could use AppleScript’s text item delimeters to search for Panel ID but i don’t know how I can capture the number after it or if this is the best way of getting the number. Please Help!!
Hi,
something like this
set a to "Lorem ipsum dolor sit amet Panel ID 349857698
consectetuer adipiscing elit Panel ID 795806987. Ut neque lectus
varius eu, Panel ID 823646374, vitae dui auctor porttitor"
set theList to {}
set {TID, text item delimiters} to {text item delimiters, "Panel ID "}
tell text items of a
if (count it) > 1 then
repeat with i from 2 to count it
set end of theList to word 1 of item i
end repeat
end if
end tell
set text item delimiters to TID
theList --> {"349857698", "795806987", "823646374"}
Hi Stefan,
I was hoping you would reply, when I run the code it only gives me a list of the first number of the Panel ID not the full number e.g “8”,“8” etc instead of “81234567”,“82345678” is it the way I’m reading the text file?
set the_text_file to (path to the desktop as string) & "PanelLocations.txt" as alias
set theText to read the_text_file
set theList to {}
set {TID, text item delimiters} to {text item delimiters, "P
sorry, there must be something in the Panel ID that this HTML doesn’t like and keeps displaying my posts wrong
Hi Stefan,
There’s nothing wrong with your code it’s the way that I’m writing the text I think. To get the text file im copying the text from a pdf and then writing it to a fileRef. If I then open that text file in BBEdit and show invisibles I can see lots of strange characters between each letter which explains why I’m only getting the first number from your code and why my posts on this site keep screwing up. I’ve now placed the text into a text edit document and then when I read that text file the Panel ID numbers appear correct using your code. Many thanks again
The problem is obviously a question of text encoding.
read file reads the text as MacRoman, but if the source is UTF-8 or UTF-16, you get an odd result
You truly are a font of all knowledge,
Thanks again, I’m sure I’ll have another question soon