https://github.com/erremauro/csvbot
Rearrange and rename columns in csv files and move them around
https://github.com/erremauro/csvbot
copy csv move rename
Last synced: 10 months ago
JSON representation
Rearrange and rename columns in csv files and move them around
- Host: GitHub
- URL: https://github.com/erremauro/csvbot
- Owner: erremauro
- License: mit
- Created: 2017-12-15T23:10:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-15T23:11:07.000Z (over 8 years ago)
- Last Synced: 2025-03-23T11:31:00.362Z (about 1 year ago)
- Topics: copy, csv, move, rename
- Language: C#
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# csvbot
CSVBot is an utility to move, copy and rename columns in a `*.csv` file by
defining a `FileStrategy` and `Directives`.
## Table of content
- [Configurations](#configurations)
- [Defining a Source](#defining-a-source)
- [File Strategies](#file-strategies)
- [Accepted overwrite values](#accepted-overwrite-attribute-values)
- [Moving and copying a group of iles](#moving-and-copying-a-group-of-files)
- [Directive](#directives)
- [Accepted directive attributes](#accepted-directives-attributes)
- [Separator](#separator)
- [Logs](#logs)
## Configurations
All configurations can be specified in `config.xml` via xml Elements and
attributes inside the `` root node.
Here's a `config.xml` example:
```xml
txt,tif
;
```
## Defining a source
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:
```xml
```
## File Strategies
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.
```xml
```
### Accepted overwrite attribute values
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 |
### Moving and Copying a group of files
You can use a `GroupedWith` container or a `FileStrategy`'s `with` attribute to
move or copy a group of additinal files besides your csv.
```xml
txt
```
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.
## Directives
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:
```xml
```
### Directive attributes
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 |
## Separator
You can specify a custom csv separator in a `Separator` element inside the
`Config` root node:
```xml
;
```
## Logs
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.