Miscellaneous

Time

scan.util.seconds.parseSeconds(text)

Parse various time durations into seconds

Parameters

text – Text that contains a duration

Returns

Seconds

Convert text that contains “HH:MM:SS” into seconds

>>> parseSeconds("00:00:01")
1
>>> parseSeconds("120")
120.0
>>> parseSeconds("6.0")
6.0
>>> parseSeconds("13.4")
13.4
>>> parseSeconds("01:01:01")
3661
>>> parseSeconds("2:01")
121
>>> parseSeconds("02:01")
121
>>> parseSeconds("48000")
48000.0

Can also be called with number:

>>> parseSeconds(120)
120

Spreadsheets

scan.util.spreadsheet.readSpreadsheet(filename)

Read a spreadsheet file.

Reads the basic table of strings and numbers from a gnumeric file.

Parameters

filename – Name of file to read, either ‘.cvs’, ‘.tab’, ‘.xls’ or ‘.gnumeric’

Returns

[ [ row0cell0, row0cell1 ], [ row1cell0, row1cell1 ], … ]

Example:

>>> table = readSpreadsheet('/path/to/file.csv')
>>> print table
scan.util.spreadsheet.writeSpreadsheet(filename, table)

Save table to file

Writes table as spreadsheet file.

Parameters
  • filename – File path, must end in “.csv” or “.tab”

  • table – Table [ [ row0cell0, row0cell1 ], [ row1cell0, row1cell1 ], … ]

Example:

>>> writeSpreadsheet('/path/to/file.csv', [ [ 'X', 'Y' ], [ 1, 2 ], [ 3, 4 ] ])