Evening all, I am trying to do something that is probably very trivial, but which eludes me. I have a number of data points in a text file that I want to use. The data looks like this:
What I want the script to do is to take each number and put that into a variable, so varable1 will equal 43.83, variable2 will equal 18.45, etc. I’m sure that is easy to do (especially as the data is tab seperated), but I can’t figure it. Anyone?
Hi,
assuming there is one text line with 4 values tab delimited, this is the easiest way.
The variables contain text, so coerce each of them to number if you want to do some math.
set textFile to ((path to desktop as text) & "ttt.txt")
set theLine to 1st paragraph of (read file textFile)
set {TID, text item delimiters} to {text item delimiters, tab}
set {variable1, variable2, variable3, variable4} to text items of theLine
set text item delimiters to TID
Perfect, thanks. Actually, there are multiple lines of text, but this is part of a loop, and I can adapt this pretty easily. Thanks again!