Events-csv User Manual: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(49 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Overview=
=Overview=


Usage:
"csv" assumes that the input file or piped content is text comma-separated content and parses it, generating [[Events-api_Concepts#Event|events]], which then are optionally filtered by the query and processed depending on the command specified on command line.


  tail -f input.csv | csv [''query''] [-o ''output-spec'']  
  csv [''[[#Commands|command]]''] [''[[Events-api_Concepts#Query|query]]''] <input-file.csv>


  csv [''query''] [-o ''output-spec''] <input-file.csv>
The default command, which does not need to be specified on the command line, is [[Events-processing output|output]]: the CSV content is parsed and the resulted events are optionally filtered and displayed at stdout:
 
  csv [''[[Events-api_Concepts#Query|query]]''] [-o ''output-spec''] <input-file.csv>
 
Alternatively, the content can be sent into "csv" with a pipe:
 
tail -f input.csv | csv [''[[#Commands|command]]''] [''[[Events-api_Concepts#Query|query]]'']


=Concepts=
=Concepts=
Line 15: Line 21:
{{Internal|events-csv Concepts|events-csv Concepts}}
{{Internal|events-csv Concepts|events-csv Concepts}}


=CSV Format=
=Commands=
 
==output==
 
This is the default command, and does not need to be specified on the command line. More details about the output specification is available here:
 
{{Internal|Events-processing output|output}}
 
==headers==
 
csv header|headers &#91;[[#--first|--first]]|[[#--last|--last]]] [''[[#Header_Name_Regular_Expression|header-name-regular-expression]]''] <''file-name.csv''>
 
Scan the CSV stream and display the headers, as they are identified in the stream. The command displays the header's line number, the timestamp of the event that immediately follows the header, and then:
* the index that can be used to access the value that corresponds the header in a data lines. The index can be used for [[Events-processing_output#Displaying_Properties_with_a_Specific_Index|index-based output]].
* the header name.
* the header type.
* optionally, the header format.
 
===Usage Example===
<pre>
csv headers ./sample.csv


==CSV Field==
line 1 header, applies to events recorded on 12/01/16 00:00:00 and after:
  0: timestamp(time:MM/dd/yy HH:mm:ss)
  2: interior-color(string)
  3: exterior-color(string)
  4: size(int)
</pre>


===CSV Field Specification===
<pre>
csv headers 'color' ./sample.csv


"timestamp"
line 1 header, applies to events recorded on 12/01/16 00:00:00 and after:
  2: interior-color(string)
  3: exterior-color(string)
</pre>


"timestamp(time:yy/MM/dd HH:mm:ss)"
===Modifiers===


"something"
====--first====


"something(string)"
Display the first encountered header and exit.


"something(int)"
====--last====


"something(long)"
Display the last encountered header, without displaying all previous ones, and exit.


"something(float)"
====Header Name Regular Expression====


"something(double)"
The first command argument following the header command name that is not one of the modifiers described above will be interpreted as a regular expression to be applied to header names. Only the header names that produce a match will be displayed. If none of the headers match, a warning message will be issued:


"something(time)"
line 1 header, applies to events recorded on 12/01/16 00:00:00 and after: no header name matched regular expression '^.*no-such-header.*$'

Latest revision as of 05:04, 23 September 2017

Internal

Overview

"csv" assumes that the input file or piped content is text comma-separated content and parses it, generating events, which then are optionally filtered by the query and processed depending on the command specified on command line.

csv [command] [query] <input-file.csv>

The default command, which does not need to be specified on the command line, is output: the CSV content is parsed and the resulted events are optionally filtered and displayed at stdout:

csv [query] [-o output-spec] <input-file.csv>

Alternatively, the content can be sent into "csv" with a pipe:

tail -f input.csv | csv [command] [query]

Concepts

events-csv Concepts

Commands

output

This is the default command, and does not need to be specified on the command line. More details about the output specification is available here:

output

headers

csv header|headers [--first|--last] [header-name-regular-expression] <file-name.csv>

Scan the CSV stream and display the headers, as they are identified in the stream. The command displays the header's line number, the timestamp of the event that immediately follows the header, and then:

  • the index that can be used to access the value that corresponds the header in a data lines. The index can be used for index-based output.
  • the header name.
  • the header type.
  • optionally, the header format.

Usage Example

csv headers ./sample.csv

line 1 header, applies to events recorded on 12/01/16 00:00:00 and after:
  0: timestamp(time:MM/dd/yy HH:mm:ss)
  2: interior-color(string)
  3: exterior-color(string)
  4: size(int)
csv headers 'color' ./sample.csv

line 1 header, applies to events recorded on 12/01/16 00:00:00 and after:
  2: interior-color(string)
  3: exterior-color(string)

Modifiers

--first

Display the first encountered header and exit.

--last

Display the last encountered header, without displaying all previous ones, and exit.

Header Name Regular Expression

The first command argument following the header command name that is not one of the modifiers described above will be interpreted as a regular expression to be applied to header names. Only the header names that produce a match will be displayed. If none of the headers match, a warning message will be issued:

line 1 header, applies to events recorded on 12/01/16 00:00:00 and after: no header name matched regular expression '^.*no-such-header.*$'