importing data and deleting info
Howard Bornstein
bornstein at designeq.com
Sat Jul 20 00:17:01 EDT 2002
>I'm importing data from external files, but I don't want the first three
>characters of each line to be there (they are numbers to keep track of data.
>Ex. 001 = the 1st 3 char of line 1, 002 = the 1st 3 char of line 2, etc.)
Assuming that you *always* want to delete exactly 3 characters at the
beginning of each line, here's a simple method:
-- Read your file into a variable. In this example, "fileData".
-- To get rid of the first 3 characters of each line...
repeat for each line theline in fileData
delete char 1 to 3 of theline
put theline&return after newFileData
end repeat
--variable newFileData now contains your "clean" data.
>Also, can I tell Revolution to get the specific external file and
>automatically delete the unwanted info as it comes in, or do I have to put
>the info into a separate variable before it will work?
While you could probably read in a record at a time an process each
record after it is read, it's *much* faster to do it as a batch after the
whole file is read in. The "Repeat For Each" structure is blazingly fast.
Regards,
Howard Bornstein
____________________
D E S I G N E Q
www.designeq.com
More information about the use-livecode
mailing list