Re: counting the records in a tab-delimited text file
Re: counting the records in a tab-delimited text file
- Subject: Re: counting the records in a tab-delimited text file
- From: Bill White <email@hidden>
- Date: Fri, 21 Dec 2001 14:55:10 -0500
>
Can anyone give me a simple way of counting the number of records
>
(return-delimited records) in a tab-delimited text file? I know I can go
>
through and read each character, counting each return, but that seems like a
>
really inefficient way of getting the count. Thanks in advance,
>
Try using text item delimiters:
set theFile to read file "Hard drive:Desktop folder:Text file" -- change to
suit
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set recordCount to (count (text items of theFile)) - 1
set AppleScript's text item delimiters to oldDelims
return recordCount
HTH,
Bill