The first method is to use the column mode.
- Click on Column - Column Mode to activate the column mode editing.
- Set in the first line the cursor to the first column where you want to insert a comma.
- Click on Column - Insert/Fill Columns, enter the comma and press button OK.
- Move the cursor to the next column where you want to insert a comma.
- Click on Column - Insert/Fill Columns (use hotkey!) and press button OK.
- Redo step 4 and 5 until all commas are inserted.
- Turn column mode off with a click on Column - Column Mode.
Big advantage of this method: You can be sure to insert every comma always at the correct column.
The second method is to use Column - Convert to Character Delimited
, a command written to convert a fixed width file into a CSV file. It is fast and easy to handle, but you need to know how many characters every field has, for example according to your question 16, 55-16 = 39, 62-55 = 7, ... So it is possible that you insert a comma at the wrong column when you make a mistake on calculating the field widths. Also after executing the command you can't undo the changes. Therefore it is good advice to always save a file before running this command to be able to use File - Revert to Saved
if the result is not what has been expected.
Hint: Before opening the dialog, select the characters of every field once. At bottom of the UltraEdit main window in the status bar is displayed how many bytes are selected. For an ASCII/ANSI file this is the field width, for a Unicode file the number of selected bytes must be divided by 2. So you can easily find out and note anywhere the widths of every field.
The third method would be to use a Perl regular expression with following syntax for the search string:
and for the replace string:
start every search a start of a line.(...)
means store the string found by the expression inside () temporarily for re-use it in the replace step (or even as back reference in the search)..
means any single character except new line characters - all characters except CR and LF.
} means the preceding expression - here any character except CRLF - x
times. So x
would be for your task 16, 55-16 = 39, 62-55 = 7, ...
This method is definitely the most complicated method to convert a file from fixed column to CSV.
A fourth method would be to use Insert String At Every Increment
. Similar to the first method you would have to place the cursor always at correct column position in the first line, insert there the comma and then run this command for inserting the comma in all other lines too. The file increment value would be the line length including the 2 not displayed line ending characters CR and LF (for DOS files). And of course this increment value increases with every execution by 1 because of the inserted comma.