PyDL:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- pydl v0.6.0 »
- PyDL »
- file_lines

# file_lines

`pydl.``file_lines`(path, compress=False)

  Replicates the IDL `FILE_LINES()` function.

  Given a path to a file name or a list of such paths, returns the number of lines in the file(s).

  Parameters:

  path : `str` or `list` of `str`

  > Path to a file. Can be a list of paths.

  compress : `bool`, optional

  > If set to `True`, assumes that all files in `path` are GZIP compressed.

  Returns:

  `int` or `list` of `int`

  > The number of lines in `path`. Returns a list of lengths if a list of files is supplied.

  Notes

  The `/NOEXPAND_PATH` option in IDL’s `FILE_LINES()` is not implemented.

  References

  http://www.exelisvis.com/docs/FILE_LINES.html

  Examples

      >>> from pydl import file_lines
      >>> from os.path import dirname, join
      >>> file_lines(join(dirname(__file__),'tests','t','this-file-contains-42-lines.txt'))
      42