Records in a file

Is there a way to find the number of records in a file? [import]uid: 11571 topic_id: 5582 reply_id: 305582[/import]

Yes there is but it depends on how the records are structured. CSV? Line Delimited?

This displays a count for how many lines exist in a file:
[lua]itemCount = 0 – Initialise counter
path = system.pathForFile( “file.txt”, system.ResourceDirectory ) – Assumes file is in resource drectory
for line in io.lines( path, r ) do – Loop for each line in file
line = string.gsub( line, ‘\r’, ‘’ ) – Strip EOL chars
line = string.gsub( line, ‘\n’, ‘’ ) – Strip EOL chars
if string.len( line ) ~= 0 then – If line contains content
itemCount = itemCount + 1 – Increment counter
end
end
print( itemCount )[/lua]

If you had one record per line that would give you the correct result. If you had data elements on each line, and 2 elements per record, then you could just divide that result by 2.
[import]uid: 11393 topic_id: 5582 reply_id: 19360[/import]

Thanks! I was hoping that there was a corona function for this and I didn’t have to do my own little counter but that is fine too.

thanks again [import]uid: 11571 topic_id: 5582 reply_id: 19362[/import]