Files
cobol-java-v3/benchmark-programs/15-csv-fb-nolf/README.md
T
NB-076 94400d50d4 feat: add benchmark-programs — 58 telecom COBOL test programs
作为子目录纳入系统,与核心测试管道协同

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-25 09:53:21 +08:00

68 lines
2.3 KiB
Markdown

# 15-csv-fb-nolf: CSV to Fixed-Block Conversion (No Line Feed)
## 电信业务场景
外部CDR CSV取込(无LF)。读取外部系统提供的CSV格式CDR文件,使用STRING语句将各字段合并为固定长记录。无换行展开。
## Description
Reads a LINE SEQUENTIAL CSV file (comma-separated, 3 fields) and
converts each row to a fixed-length output record using the STRING
statement. Handles basic CSV quoting (double-quoted fields with
embedded commas).
## Record Layout
### Input (LINE SEQUENTIAL CSV)
Each line contains 3 comma-separated fields. Fields may be quoted
with double-quotes when they contain commas or leading/trailing spaces.
### Output (fixed-length: 100 bytes)
One fixed-length record per CSV row. Fields are joined with pipe ('|')
separators via STRING.
| Component | Description |
|-----------|----------------------------|
| FIELD1 | Padded/spaced as parsed |
| Separator | Pipe character '|' |
| FIELD2 | Padded/spaced as parsed |
| Separator | Pipe character '|' |
| FIELD3 | Padded/spaced as parsed |
## Files
| File | Purpose |
|-------------------------|--------------------------------|
| main-15-csv-fb-nolf.cbl | Main COBOL program |
| data-gen.sh | Generate CSV test data |
| run.sh | Compile, run, verify |
| README.md | This file |
## Tests
| Test Case | Description |
|-------------------------|-------------------------------------|
| Standard CSV | Normal comma-separated values |
| Empty middle field | Field2 is empty (,,) |
| Quoted commas | Field contains embedded comma |
| Quoted spaces | Quoted field with padding spaces |
| All empty | Line with only commas |
| Long text | Field longer than usual |
## Usage
```bash
cd 15-csv-fb-nolf
bash data-gen.sh
bash run.sh
```
## Expected Behavior
- Each CSV line produces exactly one fixed-length (100-byte) output record.
- Quoted fields are unquoted during parsing.
- Embedded commas within quoted fields are preserved.
- Output records use '|' as separator between fields.