So you want a CSV file check macro as requested also at forum topic
Counting TABs in a line and others would like to have too. I have already downloaded the CSV specification as described at
Wikipedia - Comma-separated values, but did not start to write the macro because it is really not easy, especially in the macro environment. It's much easier with a script, but still not simple.
According to the macro I have posted at
Counting TABs in a line here is something similar for you using | as delimiter instead of tabs and works on the number of | in the first line instead of a fixed number.
It works only for files with DOS line terminations. Replace all
^p with
^n if you have a UNIX file opened in UNIX mode.
The line with wrong number of columns will start after macro execution with
!!! . It is a quick and dirty solution which works only for simple CSV files with no specials like | inside "...".
The macro was only tested with UE v13.20a on a small example I have quickly created.
The macro property
Continue if a Find with Replace not found or
Continue if search string not found must be checked for this macro.
InsertMode
ColumnModeOff
HexOff
UnixReOff
Bottom
IfColNum 1
Else
"
"
EndIf
Top
Find RegExp "%»"
Replace All "MaRkErChAr1"
Find "«"
Replace All "MaRkErChAr2"
Find "^p"
Replace All "«^p"
DupeLine
Top
SelectLine
Find RegExp "[~|^p]"
Replace All SelectText ""
Top
SelectLine
Find "|"
Replace All SelectText "[~|«]++|"
Top
"%^("
Key END
"«^)"
Clipboard 9
StartSelect
Key HOME
Cut
EndSelect
Find RegExp "^c"
Replace All "»^1"
Delete
Paste
Key LEFT ARROW
Key LEFT ARROW
Key LEFT ARROW
"[~|«]+"
Key END
StartSelect
Key HOME
Cut
EndSelect
Delete
Find RegExp "^c"
Replace All "»^1"
Find RegExp "%^([~»]*^)«"
Replace All "!!!^1«"
Find RegExp "%»"
Replace All ""
Find RegExp "«$"
Replace All ""
Find MatchCase RegExp "%MaRkErChAr1"
Replace All "»"
Find MatchCase "MaRkErChAr2"
Replace All "«"
ClearClipboard
Clipboard 0
Add
UnixReOn or
PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.