(file_handle)
Generator for reading a Redline CSV file.

    Args:
        file_handle: a file-like object containing the CSV content.

    Raises:
        RuntimeError: if there are missing fields.
Generator for reading a Redline CSV file.
Generator for reading a Redline CSV file .
def read_and_validate_redline(file_handle):
    """Generator for reading a Redline CSV file.

    Args:
        file_handle: a file-like object containing the CSV content.

    Raises:
        RuntimeError: if there are missing fields.
    """

    csv.register_dialect(
        'redlineDialect', delimiter=',', quoting=csv.QUOTE_ALL,
        skipinitialspace=True)
    reader = pandas.read_csv(file_handle, delimiter=',',
                             dialect='redlineDialect')

    _validate_csv_fields(REDLINE_FIELDS, reader)
    for row in reader:
        dt = parser.parse(row['Timestamp'])
        timestamp = int(time.mktime(dt.timetuple())) * 1000
        dt_iso_format = dt.isoformat()
        timestamp_desc = row['Field']

        summary = row['Summary']
        alert = row['Alert']
        tag = row['Tag']

        row_to_yield = {}
        row_to_yield['message'] = summary
        row_to_yield['timestamp'] = timestamp
        row_to_yield['datetime'] = dt_iso_format
        row_to_yield['timestamp_desc'] = timestamp_desc
        tags = [tag]
        row_to_yield['alert'] = alert  # Extra field
        row_to_yield['tag'] = tags  # Extra field

        yield row_to_yield
def read_and_validate_redline ( file_handle ) : csv . register_dialect ( 'redlineDialect' , delimiter = ',' , quoting = csv . QUOTE_ALL , skipinitialspace = True ) reader = pandas . read_csv ( file_handle , delimiter = ',' , dialect = 'redlineDialect' ) _validate_csv_fields ( REDLINE_FIELDS , reader ) for row in reader : dt = parser . parse ( row [ 'Timestamp' ] ) timestamp = int ( time . mktime ( dt . timetuple ( ) ) ) * 1000 dt_iso_format = dt . isoformat ( ) timestamp_desc = row [ 'Field' ] summary = row [ 'Summary' ] alert = row [ 'Alert' ] tag = row [ 'Tag' ] row_to_yield = { } row_to_yield [ 'message' ] = summary row_to_yield [ 'timestamp' ] = timestamp row_to_yield [ 'datetime' ] = dt_iso_format row_to_yield [ 'timestamp_desc' ] = timestamp_desc tags = [ tag ] row_to_yield [ 'alert' ] = alert # Extra field row_to_yield [ 'tag' ] = tags # Extra field yield row_to_yield