CSV to XML Converter

21
CSV to XML Converter Converts Comma-Separated-Value files to Xcelsius SAP BO Dashboards 4.x compliant XML- files Copyright Gino Scheppers csv XML csv csv XML XML

Transcript of CSV to XML Converter

Page 1: CSV to XML Converter

CSV to XML Converter

Converts Comma-Separated-Value

files to Xcelsius – SAP BO

Dashboards 4.x compliant XML-

files

Copyright – Gino Scheppers

csv

XML

csvcsv

XMLXML

Page 2: CSV to XML Converter

CSVtoXML

CSVtoXML (CSVtoXML.jar) is a „command-line driven‟ Java-program, it converts one or more CSV-files to one or more Xcelsius & SAP BO Dashboards 4.x compliant XML-files.

The program is platform independent. Runs in Windows, Sun Solaris, Unix, Linux,…

CSVtoXML is freeware.

Requisites:

Java JRE 1.5 or higher

Page 3: CSV to XML Converter

CSVtoXML

Running the program with the –Help option, will result in an overview of all the available parameters.

Cmd: java –jar <installdir>\CSVtoXML.jar -Help

Page 4: CSV to XML Converter

CSVtoXML

The program is a command-line driven java program, that can run from within a batch-file or script-file (like *.cmd, *. bat, …).

Usage:

java -jar <install dir>CSVtoXML.jar [Options]

Example:

java -jar “C:\Program Files\csvtoxml\CSVtoXML.jar” -Help

Important !

All command-line-options are case-sensitive !

usage:

Page 5: CSV to XML Converter

CSVtoXML

Option: -Help

Shows all parameter options

Usage:

java -jar <install dir>CSVtoXML.jar -Help

Example:

java -jar “C:\Program Files\csvtoxml\CSVtoXML.jar” -Help

Option overview:

Page 6: CSV to XML Converter

CSVtoXML

Option: -cleanDirectory

This option will clean the source-folder after the conversion process.

Important: this option will clean the complete folder! In this case, the output-folder should be different from the source-folder, otherwise you will end-up with no files!

Usage:

java -jar <install dir>CSVtoXML.jar -cleanDirectory -sourceFolderc:/temp/csv -destinationFolder c:/temp/xml

The above example will convert all files with extension *.txt and *.csv (=default behavior) in the source-folder to the destination-folder, after the conversion, all files in the source-folder will be deleted.

Option overview:

Page 7: CSV to XML Converter

CSVtoXML

Option: -csvFilename <arg>

Use this option to indicate the file to convert

Important: Use slash instead of backslash in the path definition

<arg> = <drive:/path/filename>

<arg> = <//server/share/path/filename>

Usage:

java -jar <install dir>CSVtoXML.jar -csvFilenamec:/temp/csv/kpi.csv The above example will convert the file kpi.csv to kpi.xml in the folder

c:\temp\xml.

java -jar <install dir>CSVtoXML.jar -csvFilename kpi.csv -sourceFolder c:/temp/csv/ -destionationFolder c:/temp/xml In the above example, the converted file will be placed in the folder c:\temp\xml

Option overview:

Page 8: CSV to XML Converter

CSVtoXML

Option -sourceFolder <arg>

Use this option to indicate the source path

Important:

Use slash instead of backslash in the path definition <arg> = <drive:/path/>

<arg> = <//server/share/path/>

Using this option without the -csvFilename option will convert allfiles in the source-folder

Usage – example:

java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ The above example will convert all files (with extension *.csv and *.txt) in the

folder c:\temp\csv. The result will be placed in the same folder

Option overview:

Page 9: CSV to XML Converter

CSVtoXML

Option: -destinationFolder <arg>

Use this option to indicate the destination path

Important:

Use slash instead of backslash in the path definition <arg> = <drive:/path/>

<arg> = <//server/share/path/>

If you don‟t use this option, all converted files will be placed into the source-folder

Tip: if the target-folder doesn‟t exist, it will be created by the program.

Usage: java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ -

destinationFolder c:/temp/xml The above example will convert all files (with extension *.csv and *.txt) in the

folder c:\temp\csv. The result will be placed in c:\temp\xml

Option overview:

Page 10: CSV to XML Converter

CSVtoXML

Option: -xmlFilename <arg>

Default: the source-file name will be used as destination-file name, use this option if you want to rename the destination filename into another filename.

Important: you can use the merge-option (see next slide) if you want to merge all files into

one file.

Usage:

java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ -destionationFolder c:/temp/xml -csvFilename kpi.csv -xmlFilenamemyXML.xml

The above example will convert the file kpi.csv in the folder c:\temp\csv into the xml-file myXML.xml in the directory c:\temp\xml

Option overview:

Page 11: CSV to XML Converter

CSVtoXML

Option: -merge

Use this option to merge all the converted files into one xml-file

Important: Use this option in combination with the –xmlFilename option

Usage – example:

java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ -destionationFolder c:/temp/xml -merge -xmlFilename myXML.xml

The above example will convert all files (with extension *.csv and *.txt) in the folder c:\temp\csv into one xml-file (myXML.xml) into the directory c:\temp\xml

The source-filename without extension will be used as variable tag-name.

Option overview:

Page 12: CSV to XML Converter

CSVtoXML

Option: -variableNameRange <arg>

Default, the name of the source-file (without extension) will be used as variable name tag, use this option if you want to change the <variable name>-tag into another name.

Important: Don‟t use this option in combination with the –merge option

Usage – example:

java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ -destionationFolder c:/temp/xml -csvFilename kpi.csv -variableNameRange kpi -xmlFilename myXML.xml

The above example will convert the file kpi.csv in the folder c:\temp\csv into one xml-file (myXML.xml) into the directory c:\temp\xml using kpi as variable-name tag.

Option oveview:

Page 13: CSV to XML Converter

CSVtoXML

Option: -zipFilename <arg>

Use this option to indicate the name of the backup-file

Important:

Use slash instead of backslash in the path definition <arg> = <drive:/path/filename>

<arg> = <//server/share/path/filename>

If the target folder doesn‟t exist, it will be created.

Using #date# or #datetime# in the name to replace it with the current date (format: yyyyMMdd ) or with the current timestamp (format: yyyyMMdd_HHmmss)

Usage – example:

java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ -zipFilename c:/temp/zip/myZip#date#.zip The above example will convert all files (with extension *.csv and *.txt) in the

folder c:\temp\zip, and zip into the file myZip20121101.zip

Option overview:

Page 14: CSV to XML Converter

CSVtoXML

Option: -extensionFilter <arg>

Default all files with extension *.csv and *.txt will be converted, use this option if you want to specify files with an other extension.

Important: Use ; as delimiter if you want to specify more then one extension.

Usage – example:

java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ -extensionFilter csv;txt;prn The above example will convert all files with extension *.csv, *.txt and *.prn in the

folder c:\temp\csv, into the same folder

Option overview:

convert

Page 15: CSV to XML Converter

CSVtoXML

Option: -delimiter <arg>

Default ; is used as delimiter in the csv-file, use this option if you want to use an other delimiter.

Usage – example:

java -jar <install dir>CSVtoXML.jar -sourceFolder c:/temp/csv/ -delimiter # The above example will convert all files with extension *.csv, *.txt in the folder

c:\temp\csv, into the same folder, using a crossroad (#) as delimiter.

Option overview:

csv

xml

Page 16: CSV to XML Converter

Example: converting two csv-files to one xml-file

Suppose you want to monitor the number of BO accounts in a three pillar environment (dev,

accept & production) on two different BO installations (Infra. One & Infra. Two)

On a daily basis you receive two csv-files (InfraOne.csv and InfraTwo.csv) in the C:\tmp\csv

folder.

Create a cmd-file with the following command to convert the two csv‟s to one xml-file.

java -jar CSVtoXML.jar -sourceFolder "C:/tmp/csv/" -destinationFolder "C:/tmp/xml/" -

merge -xmlFilename MergedXML.xml

Create a dashboard using the XML-data connector

read the next slides for more info

Page 17: CSV to XML Converter

Example: converting two csv-files to one xml-file

Convert with CSVtoXML.jar

DWH

Query & Export to csv

Page 18: CSV to XML Converter

Example: converting two csv-files to one xml-file

Page 19: CSV to XML Converter

Example: converting two csv-files to one xml-file

Tip: define two Excel Named Ranges

with the same name of your variable

name – tag

Important: The Import Named Ranges-

button imports the Excel ranges, not the

variable name-section in the xml-file!

Page 20: CSV to XML Converter

Example: converting two csv-files to one xml-file

Refreshing your dashboard with new xml-data will result in a ‘Cannot Access External

Data’ error message. You will need to make a trusted version of your swf-file!

Steps1. Right-click on the swf in the browser and click on Global Settings…

2. Click on the Advanced-tab and click on the Trusted Location Settings-

button

3. Add the name of the swf-file as trusted file

4. Restart your dashboard in the browser

Page 21: CSV to XML Converter

Logging Services

Default „Log4j 1.2.16‟ from apache.org is used to

log the program activity.

Read http://logging.apache.org/log4j/1.2/ for more

info.

Tip: replace the original log4j.properties file in

CSVtoXML.jar (use winzip to open the jar) with your own

configuration file to customize the logging output.

More info: http://www.tutorialspoint.com/log4j/log4j_configuration.htm

http://logging.apache.org/log4j/1.2//apidocs/org/apache/log4j/EnhancedPatternLayout.html