Editing CSV files
- Modifying cell contents
- Adding a row
- Deleting rows
- Copying a table to the clipboard or saving table in a file
- Changing table output format
- Sorting data
- Hiding columns
- Using the Structure view to sort data, and hide and show columns
- The Data tab doesn't show up. Why?
For working with comma-separated values (CSV) text files, IntelliJ IDEA provides an alternative, table view. This view opens on a separate Data tab when you open an appropriate file in the editor. (If you have just created a text file and added data into it, for the Data tab to become available, you may need to reopen the file.)
Most of the functions available in the table view are accessed as context menu commands. The context menu opens when you right-click the table. Many of the commands have keyboard shortcuts.
Note that the context menus for the header row and the rest of the table are different.
Before you start working with CSV files, make sure that Database Tools and SQL plugin is enabled. The plugin is bundled with IntelliJ IDEA and activated by default. If it is not, enable the plugin as described in the section Enabling and Disabling Plugins.
Modifying cell contents
To start editing
do one of the following:
- Double-click the corresponding table cell.
- Right-click the cell and select Edit Value from the context menu.
- Select the cell and press F2.
- Select the cell and start typing. Note that in this case the initial cell contents are deleted right away and is replaced with the typed value.
When in the editing mode, you can:
- Modify the value right in the cell. To start a new line, use Ctrl+Enter. To save the changes, press Enter. To restore an initial value and quit the editing mode, press Escape.
Replace the current value with
null. To do that, click or press Shift+Enter, and select Set NULL.
Note that you can get similar result for a cell or a range of cells by using the Set NULL context menu command or Ctrl+Alt+N.
Adding a row
To start adding a row, do one of the following:
- Right-click the table and select Add New Row from the context menu.
- Press Alt+Insert.
Note that the context menu Clone Row command (Ctrl+D) can be used as an alternative.
- Enter the values into the cells. For instructions, see Modifying cell contents.
- To save the new row, select Submit New Row from the context menu or press Ctrl+Enter.
Select the row or rows that you want to delete.
Rows are selected by clicking the cells in the column where the row numbers are shown. To select more than one row, use mouse clicks in combination with the Ctrl key.
- Press Ctrl+Y or Delete.
- Confirm you intention to delete the selected row or rows.
Copying a table to the clipboard or saving table in a file
- Right-click the table and select Copy All To Clipboard or Save All To File from the context menu.
- If you are saving the table in a file, specify the file name and location.
See also, Changing table output format.
Changing table output format
Several output formats are available for copying tables to the clipboard or saving them in files. (The output formats, in IntelliJ IDEA are called data extractors.)
When using the Copy All To Clipboard or Save All To File command, or copying a range of cells to the clipboard, the output format (the extractor) which is currently active is used.
To make a different extractor active or to create a new extractor:
- Right-click the table and point to Data Extractor: <extractor_name> in the context menu.
Do one of the following:
- To make a different extractor active, click the name of the desired extractor.
- To create a new extractor, or to view or modify the settings for an existing extractor, click Configure Extractors. As a result, the Data Extractors dialog will open.
You can sort table data by any of the columns by clicking the cells in the header row.
- If you click a cell once, the data is sorted by the corresponding column in the ascending order.
- When you click the cell for the second time, the data is sorted in the descending order.
- Finally, when you click the cell for the third time, the initial state is resorted. That is, sorting by the corresponding column is canceled.
To hide a column, right-click the corresponding header cell and select Hide column.
Using the Structure view to sort data, and hide and show columns
When working with a table, the table structure view is available in the Structure tool window or as the corresponding popup.
The structure view shows the list of all the columns and lets you sort the data as well as hide and show the columns.
To open the Structure tool window, do one of the following:
- Select in the main menu.
- Click Structure on the left-hand tool window bar.
- Press Alt+7.
To open the structure popup, do one of the following:
- Right-click a cell in the table header row and select Column List.
- Press Ctrl+F12.
In the tool window or the popup, select the column of interest and do one of the following:
- To sort the data by this column in the ascending order, press Shift+Alt+Up. (In the tool window, you can, alternatively, select from the context menu.)
- To sort the data in the descending order, press Shift+Alt+Down. (In the tool window, alternatively, .)
- To cancel sorting by this column, press Ctrl+Shift+Alt+Backspace. (In the tool window, alternatively, .)
- To hide the column (or show a hidden column), press Space. (The names of hidden columns are shown struck through. In the tool window, alternatively, the Hide Column or Show Column context menu command can be used.)
The shortcuts for sorting table data (Shift+Alt+Up, Shift+Alt+Down and Ctrl+Shift+Alt+Backspace) can be used even without opening the structure view.
The Data tab doesn't show up. Why?
For the table view and associated features to be available:
- You should be using the Ultimate Edition of IntelliJ IDEA. (The corresponding functionality is not available in the Community Edition.)
- The Database Tools and SQL plugin must be enabled. (This plugin is bundled with the IDE and enabled by default.)
- There must not be empty lines in your file, e.g. at the end.
- The file name extension must be associated with the text file type.
- The file should contain at least two lines and two "columns".