Files
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

2.3 KiB

21-csv-fb-lf: CSV to Fixed-Block Conversion (with Line Feed)

电信业务场景

外部CDR CSV取込(有LF)。读取含改行的CSV格式CDR文件,通过INSPECT REPLACING将改行展开为多条固定长记录。

Description

Reads a LINE SEQUENTIAL CSV file where Field3 may contain pipe ('|') markers that indicate record-splitting points. Uses INSPECT TALLYING to count markers and INSPECT REPLACING to transform them, then writes one output record per segment. One CSV input line can produce multiple output records ("line feed expansion").

Record Layout

Input (LINE SEQUENTIAL CSV)

Field Description
FIELD1 Key code
FIELD2 Group identifier
FIELD3 Data values (may contain '

Field3 with '|' markers:

ITEM1|ITEM2|ITEM3   -> produces 3 output records

Output (fixed-length: 100 bytes)

Format: FIELD1|FIELD2|SEGMENT padded to 100 bytes.

Files

File Purpose
main-21-csv-fb-lf.cbl Main COBOL program
data-gen.sh Generate CSV test data
run.sh Compile, run, verify
README.md This file

Tests

Test Case Description
No pipe markers 1:1 mapping, no expansion
Single pipe 1 input line -> 2 output records
Double pipe 1 input line -> 3 output records
Empty field3 Empty field handling
Leading pipe Leading empty segment
Trailing pipe Trailing empty segment
Multiple segments Many markers in one field
Quoted pipe Pipe within quotes (literal)

Usage

cd 21-csv-fb-lf
bash data-gen.sh
bash run.sh

Expected Behavior

  • Each '|' separator produces an additional output record.
  • INSPECT TALLYING counts the markers.
  • INSPECT REPLACING transforms markers for processing.
  • Output records are fixed-length (100 bytes).