Home » Support » Tutorials/Power Tips » UltraEdit » Working with CSV files

IDM PowerTips

Working with CSV files

Many of us work with character separated value files which need to be manipulated in some form or fashion. These CSV files can be somtimes difficult to deal with when each field has a different width. UltraEdit can be particularly useful where column manipulation is required, because of its "Convert to Fixed Column" and "Convert to Character Delimited" functions. Using these powerful features of UltraEdit/UEStudio you can convert a file from character delimited fields to fixed columns and back.

Working with CSV (Comma Separated Values) Files


Step 1: Converting to Fixed Column

Open the csv file you are going to be working with.

CSV Files in UltraEdit

With the csv file the active file, go to the Column menu and click on Convert to Fixed Column.

You will then be presented with the Convert to Fixed Columns dialog. Configure the options accordingly. A brief explanation of each option follows:

Scan
The editor will scan the file (or first line) and determine the maximum field widths for each field. This will determine the maximum width required for each field and place the results (comma separated) in the Field Widths entry box.

Scan First Line Only
This instructs the editor to search just the first line for the field widths.

Keep Delimiter with Fixed Columns
If this is not checked, the conversion will remove the delimiter between fields. Conversely, If it is checked, the delimiter character for the fields will not be removed.

Separator Character
This specifies the delimiter character between fields. If this is a TAB character "^t" should be entered. In all other cases, a single character should be entered. The editor uses this character to determine the field boundaries.

Field Widths
This is a list of comma separated field widths used for the conversion. If there are more fields than entries, the last entry will be used as the field width for the remaining fields. This allows the user to set a single entry if all fields are required to be the same width.

Convert
This performs the conversion from character delimited text to fixed column according to the settings above.

For this example, we are going to use the following configuration:

CSV Files in UltraEdit

Click Scan. As mentioned above, this will scan the file (or first line) and determine the maximum field widths for each field. You should then see the field widths field populated with the column width values.

CSV Files in UltraEdit

Click Convert. You will see the file has been converted.

CSV Files in UltraEdit


Step 2: Convert to Character Delimited

If you need to convert the file back from fixed columns, you can use the Convert to Character Delimited in the Column menu.

CSV Files in UltraEdit

A brief explanation of the features in the Convert to Character Delimited dialog follows:

Separator Character
This specifies the delimiter character between fields. If this is a TAB character "^t" should be entered. In all other cases, a single character should be entered. The editor uses this character to separate the fields when converting from fixed widths to character delimited.

Field Widths
This is a list of comma separated field widths used for the conversion. If there are more fields than entries, the last entry will be used as the field width for the remaining fields. This allows the user to set a single entry if all fields are required to be the same width.

Convert
This performs the conversion from fixed column to character delimited text according to the settings above. The complete file will be converted.

If you just converted the file to Fixed Columns, the field will be already populated with the correct values.

CSV Files in UltraEdit