Ignore:
Timestamp:
Mar 27, 2009, 4:21:20 PM (16 years ago)
Author:
rwilson
Message:

Moved file_length() to here, remove from all run_model.py directories.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/system_tools.py

    r6646 r6650  
    448448    fd.close()
    449449
    450 
     450##
     451# @brief Function to return the length of a file.
     452# @param in_file Path to file to get length of.
     453# @return Number of lines in file.
     454# @note Doesn't count '\n' characters.
     455# @note Zero byte file, returns 0.
     456# @note No \n in file at all, but >0 chars, returns 1.
     457def file_length(in_file):
     458    '''Function to return the length of a file.'''
     459
     460    fid = open(in_file)
     461    data = fid.readlines()
     462    fid.close()
     463    return len(data)
     464
     465
Note: See TracChangeset for help on using the changeset viewer.