relpipe-data/examples-grep-cut-fstab.xml
branchv_0
changeset 301 7029e6c47700
parent 244 d4f401b5f90c
child 325 4560c5623d7d
equal deleted inserted replaced
300:b9bd0f06b4a1 301:7029e6c47700
   163 
   163 
   164 		<p>
   164 		<p>
   165 			The <code>letters</code> relation stays rock steady and <code>relpipe-tr-cut 'numbers'</code> does not affect it in any way.
   165 			The <code>letters</code> relation stays rock steady and <code>relpipe-tr-cut 'numbers'</code> does not affect it in any way.
   166 		</p>
   166 		</p>
   167 		
   167 		
       
   168 		<h2>Process CSV files</h2>
       
   169 		
       
   170 		<p>
       
   171 			There are various input filters (<code>relpipe-in-*</code>), one of them is <code>relpipe-in-csv</code>
       
   172 			which converts CSV files to relational format.
       
   173 			Thus we can process standard CSV files in our relational pipelines
       
   174 			and e.g. filter records that have certain value in certain column (<code>relpipe-tr-grep</code>)
       
   175 			or keep only certain columns (<code>relpipe-tr-cut</code>).
       
   176 		</p>
       
   177 		
       
   178 		<p>
       
   179 			We may have a <code>tasks.csv</code> file containing TODOs and FIXMEs:
       
   180 		</p>
       
   181 		
       
   182 		<pre><![CDATA["file","line","type","description"
       
   183 ".hg/shelve-backup/posix_mq.patch","97","TODO","support also other encodings."
       
   184 ".hg/shelve-backup/posix_mq.patch","163","TODO","support also other encodings."
       
   185 "src/FileAttributeFinder.h","79","TODO","optional whitespace trimming or substring"
       
   186 "src/FileAttributeFinder.h","80","TODO","custom encoding + read encoding from xattr"
       
   187 "src/FileAttributeFinder.h","83","TODO","allow custom error value or fallback to HEX/Base64"
       
   188 "streamlet-examples/streamlet-common.h","286","FIXME","correct error codes"
       
   189 …]]></pre>
       
   190 
       
   191 		<p>
       
   192 			And we can process it using this pipeline:
       
   193 		</p>
       
   194 		
       
   195 		<m:pre jazyk="bash"><![CDATA[cat tasks.csv \
       
   196 	| relpipe-in-csv \
       
   197 	| relpipe-tr-grep 'csv' 'type' 'FIXME' \
       
   198 	| relpipe-tr-cut 'csv' 'file|description' \
       
   199 	| relpipe-out-tabular]]></m:pre>
       
   200 	
       
   201 		<p>and get result like this:</p>
       
   202 	
       
   203 		<pre><![CDATA[csv:
       
   204  ╭───────────────────────────────────────┬──────────────────────╮
       
   205  │ file                         (string) │ description (string) │
       
   206  ├───────────────────────────────────────┼──────────────────────┤
       
   207  │ streamlet-examples/streamlet-common.h │ correct error codes  │
       
   208  │ streamlet-examples/streamlet-common.h │ correct error codes  │
       
   209  │ streamlet-examples/Streamlet.java     │ correct error codes  │
       
   210  ╰───────────────────────────────────────┴──────────────────────╯
       
   211 Record count: 3]]></pre>
       
   212 
       
   213 	
       
   214 		<p>
       
   215 			We work with attribute (column) names, so there is no need to remember column numbers.
       
   216 			And thanks to regular expressions we can write elegant and powerful filters.
       
   217 		</p>
       
   218 
       
   219 
       
   220 		
   168 	</text>
   221 	</text>
   169 
   222 
   170 </stránka>
   223 </stránka>