scriptella.driver.csv

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » scriptella » scriptella.driver.csv 
scriptella.driver.csv

CSV Driver for Scriptella.

The driver to write and query CSV files.

Note: The driver doesn't use SQL syntax

General information

Driver class:scriptella.driver.csv.Driver
URL:CSV file URL. URIs are resolved relative to a script file directory. If url has no value the output is read from/printed to the console (System.out).
Runtime dependencies:opencsv-1.6+.jar

Driver Specific Properties

Name Description Required
encoding Specifies charset encoding of CSV files. No, the system default encoding is used.
separator The delimiter to use for separating entries when reading from or writing to files. No, the default value is ,.
quote The character to use for quoted elements when reading from or writing to files. Use empty string to suppress quoting. No, the default value is ".
headers Value of true means the first line contains headers.

Only valid for <query> elements.

No, the default value is true(first line contains column names).
eol End-Of-Line suffix.

Only valid for <script> elements.

No, the default value is \n.
trim Value of true specifies that the leading and trailing whitespaces in CSV fields should be omitted. No, the default value is true.
skip_lines The number of lines to skip before start reading. Please note that if headers=true, the actual number of skipped lines is skipped_lines+1 No, the default value is 0 (no lines are skipped).
null_string Specifies value of a string token to be parsed as Java null literal. No, by default strings are preserved, i.e. empty CSV field is parsed as empty string.

Query Syntax

The driver utilizes query by example approach for CSV content filtering. If you want to read the whole CSV simply use empty query element, otherwise specify a set of lines containing comma-separated case insensitive regular expressions.
Example:
,food
,^Beverages$
    
This query selects rows where the second column equals "Beverages" or contains "food" substring.

The columns of the matched row can be referenced by name in nested queries/scripts. It is also possible to reference columns by an index, i.e. $1, $2, ...

Script Syntax

The script syntax is simple, just specify a comma-separated set of columns.
Example:
<script>
id,priority,summary,status
1,Critical,NullPointerException in Main class,Open
</script>
    
This script writes 2 lines to the output file.

IMPORTANT: Always use commas as a column separator inside both <script> and <query> elements no matter what separator is used in files being parsed or produced. This decision allows switching between different formats like tab or semicolumn while keeping scripts and queries unchanged.

Properties substitution

In CSV script and query elements use ${property} syntax for properties/variables substition.

Examples

<connection id="in" driver="csv" url="data.csv" classpath="lib/opencsv.jar">

</connection>
<connection id="out" driver="csv" url="report.csv" classpath="lib/opencsv.jar">
    #Use empty quote to turn off quoting
    quote=
    separator=;
</connection>

<script connection-id="out">
    ID,Priority,Summary,Status
</script>

<query connection-id="in">
    <!--Empty query means select all-->
    <script connection-id="out">
        $rownum,$priority,$summary,$status
    </script>
</query>

Copies rows from data.csv file to report.csv, additionally the ID column is added. The result file will be semicolon separated.
Java Source File NameTypeComment
CsvConnection.javaClass Represents a connection to CSV file.
CsvConnectionPerfTest.javaClass Tests for scriptella.driver.csv.CsvConnection .
CsvConnectionTest.javaClass Tests for CsvConnection .
CsvProviderException.javaClass Thrown to indicate a problem with CSV file processing.
CsvQuery.javaClass Query for CSV file.
CsvQueryTest.javaClass Tests for CsvQuery .
CsvScriptTest.javaClass Tests CSV script processing.
Driver.javaClass Scriptella driver for CSV files.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.