Hi, i’m new to applescript and right now i’m writing a program which involves parsing info from files. Anyone have a good idea about how to do this? Thx
: Hi, i’m new to applescript and right now i’m writing a program
: which involves parsing info from files. Anyone have a good
: idea about how to do this? Thx
I’m afraid that you’ll need to be more specific about what you
are trying to do. What type of files are you parsing? What type of
info do you wish to extract? Are there any other applications
involved in the process, such as a word processor that is
generating the files?
We’ll do our best to help once we know what it is you need to
do.
Later,
Rob J
Thx for the reply, basicly we need to parse text files for the mac(i’m new to mac also, guess it use SimpleText for that?), retreive the lines which has the correct info which we need.(For example, if a line contains some thing like *Product: “blahblahblah”, the script need to be able to search for the keyword “*Product” in file, and once found, it will retrieve the whole line out and copy it to a string)
Thx
: I’m afraid that you’ll need to be more specific about what you
: are trying to do. What type of files are you parsing? What
: type of info do you wish to extract? Are there any other
: applications involved in the process, such as a word
: processor that is generating the files?
: We’ll do our best to help once we know what it is you need to
: do.
: Later,
: Rob J
Assuming you’re using OS9 or earlier:
Depending of the size of the file and how demanding the parsing is:
check the standard additons dictionary for the read/write/open/close commands. There are help files on these commands available in Apple’s help system (but you may need to download some files from the official website). This will force you to read one line of the file at time, parse it, then output what you need. it’ll be slow.
use a scriptable text editor, of which there are many. BBEdit’s grep commands can return a list of every line on which something is found. It and other other text editors can also repeatedly search a file until all occurance of a string are found
Use MacPerl.
If you’re on OSX, use Pearl or Ruby or Tcl or any other GREP-cabable scripting language. It’ll be faster than applescript.
mg
I parse all my data by exporting from Filemaker into Word. Remove the characters I don’t need and seperate each field w/ tab. Import into EXCEL and you’ll have seperate fields.
Select the cols you wants to parse. Go to DATA menu and select TEXT to Cols. Make sure before you do this that you INSERT and each cols after the cols you want to parse.
Try NOT to overwrite your data.
It works fine for me.
Then save the EXCEL data as text w/ TABS and import it back into Filemaker. MATCH the fields (set up the map) and import.
Done.
: Assuming you’re using OS9 or earlier: Depending of the size of the file and
: how demanding the parsing is: check the standard additons dictionary for
: the read/write/open/close commands. There are help files on these commands
: available in Apple’s help system (but you may need to download some files
: from the official website). This will force you to read one line of the
: file at time, parse it, then output what you need. it’ll be slow.
: use a scriptable text editor, of which there are many. BBEdit’s grep commands
: can return a list of every line on which something is found. It and other
: other text editors can also repeatedly search a file until all occurance
: of a string are found
: Use MacPerl.
: If you’re on OSX, use Pearl or Ruby or Tcl or any other GREP-cabable
: scripting language. It’ll be faster than applescript.
: mg