CSVBot is an utility to move, copy and rename columns in a *.csv
file by
defining a FileStrategy
and Directives
.
All configurations can be specified in config.xml
via xml Elements and
attributes inside the <Config></Config>
root node.
Here's a config.xml
example:
<Config>
<Source path="C:\mycsv" />
<FileStrategy>
<Move path="\\151.92.85.30\shared" overwrite="skip" />
<Copy path="D:\processed" with="txt" />
</FileStrategy>
<GroupedWith>txt,tif</GroupedWith>
<Directives>
<Directive position="12" action="copy" to="1" rename="Custom ID" />
<Directive position="3" rename="Image Name" />
<Directive position="7" action="move" to="4" />
</Directive>
<Separator>;</Separator>
</Config>
A source can be a file
or directory
and is a required parameter in order for
the application to work.
When a directory is specified, csvbot will process all *.csv
files found in
that directory by applying all FileStrategy
and Directives
to each file.
To specify a source use a Source
element inside the Config
root node:
<Config>
<Source path="C:\path\to\source" />
</Config>
A FileStrategy
tells csvbot what to do with the file once all Directives
has been applied. If no FileStrategy
is specified, csvbot will overwrite the
processed file directly in the source.
You can specify how many FileStrategy
you want; so you can, for example, move
the file to a location and copy it to another.
To specify a FileStrategy
use a Move
or a Copy
element inside a
FileStrategy
container in a Config
root node. Each FileStrategy
requires a
path and optional overwrite
attribute. Additionally you can specify a with
attribute to define a set of comma separated extesions that will match the
source filename and, if found, copied along.
<Config>
<FileStrategy>
<Copy path="D:\processed_files" overwrite="false" />
<Move path="\\my-host\shared" />
</FileStrategy>
</Config>
Here's a list of every accepted overwrite attribute values. When an overwrite
attribute is not specified, csvbot will assume the default value of true
.
Value | Description |
---|---|
true | Default value. Overwrites existing files |
false | Do not overwrite existing files and halt the program with an error |
skip | Do not overwrite existing files and continue without notice |
You can use a GroupedWith
container or a FileStrategy
's with
attribute to
move or copy a group of additinal files besides your csv.
<Config>
<FileStrategy>
<Copy path="D:\processed_files" />
<Move path="\\my-host\shared" with="txt,tiff" />
</FileStrategy>
<GroupedWith>txt</GroupedWith>
</Config>
Csvbot will search the source directory for files with identical name but
of specified extensions and it will move or copy those files along. Use a
GroupedWith
container to apply this behavior to every FileStrategy
or a
FileStrategy
's with
attribute to apply the behavior to selected strategies.
Use Directives
to instruct csvbot on how to manipulate your *.csv
files, by
giving the column position
and an optional action
of move
or copy
with
related to
position. You can also specify an optional rename
attribute to
rename your column.
List your directives as child of a Directives
element inside the Config
root
node:
<Config>
<Directives>
<Directive position="12" action="copy" to="1" rename="Custom ID" />
<Directive position="3" action="move" to="4" />
<Directive position="7" rename="Image Name" />
</Directives>
</Config>
Here's the accepted directive attributes
Parameter | Type | Description |
---|---|---|
position | integer | Required column position |
action | string | Optional action name. Can be: move or copy |
to | integer | Define new position if move or copy action are specified. |
rename | string | Optional column header new name |
You can specify a custom csv separator in a Separator
element inside the
Config
root node:
<Config>
<Sperator>;</Separator>
</Config>
A log.txt
file is written for debugging purposes in the csvbot directory.
The log file is automatically rolled when the file size is over 1MB.