csv2excel/README.md

73 lines
1.8 KiB
Markdown
Raw Permalink Normal View History

# csv2excel
A command-line tool that converts one or more CSV files into a single Excel (`.xlsx`) file. Each CSV file becomes a separate worksheet, named after the source file.
## Features
- Merges multiple CSV files into one Excel workbook
- Auto-detects the delimiter (`,`, `;`, `\t`)
- Supports UTF-8 and Windows-1252 encoding
- Tolerant with malformed CSV files (`LazyQuotes`)
- Version info injected at build time via git tags
## Installation
### From source
Requires [Go](https://golang.org/) 1.21+.
```bash
git clone https://code.beautifulmachines.dev/jakoubek/csv2excel
cd csv2excel
go install .
```
### Build with Mage
Requires [Mage](https://magefile.org/).
```bash
mage Build # current platform (auto)
mage BuildWindows # dist/csv2excel.exe
mage BuildLinux # dist/csv2excel
mage Install # install to $GOBIN
mage Clean # remove dist/
```
## Usage
```
csv2excel [flags] file1.csv file2.csv ...
```
### Flags
| Flag | Default | Description |
|------|---------|-------------|
| `-o` | `output.xlsx` | Output file path |
| `-sep` | `auto` | Delimiter: `auto`, `,`, `;`, `\t` |
| `-enc` | `utf8` | Encoding: `utf8`, `windows1252` |
### Examples
```bash
# Convert a single file
csv2excel data.csv
# Merge multiple files into one workbook
csv2excel -o report.xlsx sales.csv inventory.csv customers.csv
# Force semicolon delimiter, Windows-1252 encoding
csv2excel -sep ";" -enc windows1252 -o result.xlsx export.csv
```
Each CSV file becomes a worksheet named after the filename (without extension). Sheet names are truncated to 31 characters to comply with Excel's limit.
## Dependencies
- [excelize](https://github.com/xuri/excelize) — Excel file creation and manipulation
- [golang.org/x/text](https://pkg.go.dev/golang.org/x/text) — Character encoding support
## License
MIT