Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/guitarbum722/fixedtocsv
Convert a fixed width flat file to a CSV.
https://github.com/guitarbum722/fixedtocsv
csv fixed-width go golang tool transformation
Last synced: 2 days ago
JSON representation
Convert a fixed width flat file to a CSV.
- Host: GitHub
- URL: https://github.com/guitarbum722/fixedtocsv
- Owner: Guitarbum722
- License: mit
- Created: 2017-11-29T01:47:50.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-07T13:49:18.000Z (about 7 years ago)
- Last Synced: 2024-11-14T11:46:19.303Z (2 months ago)
- Topics: csv, fixed-width, go, golang, tool, transformation
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### fixedtocsv
Convert a data-positioned (fixed width) file to CSV format.
```go
go get -u github.com/Guitarbum722/fixedtocsvcd fixedtocsv
make build
```#### Usage:
```
Usage: fixedtocsv [-c] [-d] [-f] [-o]
Options:
-h | --help help
-c input configuration file (default: "config.json" in current directory)
-d output delimiter (default: comma ",")
-f input file name (Required)
-o output file name (default: "output.csv" in current directory)
```The only required flag is `-f` which specifies the input file.
A JSON or CSV file is expected to provide the configuration of the input data (being the fixed width flat file).
Currently, a file named `config.json` is expected by default. Please see the flags above to specify a different file name.
Here is an example of the configuration file. Most importantly, each object in `columnLens` represents a field in the file. The order of the fields will be evaluated in the order in which they appear in the JSON.
```json
{
"columnLens": [
{
"start": 0,
"end": 6
},
{
"start": 7,
"end": 21
}
]
}
```If you want to use a CSV for the configuration, then it should have the below format (headers are expected). You will need to use the `-csv` option AND the `-c` flag with a file name is REQUIRED in this case.
```
column,start,end
0,0,6
1,7,21
2,22,38
3,39,63
4,64,101
5,102,136
6,137,149
7,150,163
```