DataGrip 2016.2 Help

Working with delimiter-separated values

On this page:

Overview

For text files containing delimiter-separated values (e.g. CSV, TSV), DataGrip provides an alternative, table editor.

CSVTextView CSVTableView

Most of the functions in the table editor are accessed as context menu commands. Many of the commands have keyboard shortcuts.

CSVTableViewMenu

Note that the context menus for the header row and the rest of the table are different.

Prerequisites

For the table editor and associated features to be available:

  • The file name extension must be associated with the text file type. See e.g. File Types.

Opening the table editor

You can open the table editor for a whole file or for its fragment.

  1. Open the file of interest in the editor.
  2. If you want to open the table editor for a fragment, select that fragment.
  3. Select Edit as Table from the context menu.
  4. In the dialog that opens, specify conversion setting and click OK. After that, the Text and Data tabs appear.
edit_as_table

Sorting data

You can sort table data by any of the columns by clicking the cells in the header row.

Each cell in this row has a sorting marker in the right-hand part and, initially, a cell may look something like this: TableEditorHeaderCellUnsorted. The sorting marker in this case indicates that the data is not sorted by this column.

If you click the cell once, the data is sorted by the corresponding column in the ascending order. This is indicated by the sorting marker appearance: TableEditorHeaderCellSortAsc. The number to the right of the marker (1 on the picture) is the sorting level. (You can sort by more than one column. In such cases, different columns will have different sorting levels.)

When you click the cell for the second time, the data is sorted in the descending order. Here is how the sorting marker indicates this order: TableEditorHeaderCellSortDesc.

Finally, when you click the cell for the third time, the initial state is resorted. That is, sorting by the corresponding column is canceled: TableEditorHeaderCellUnsorted.

Hiding and showing columns

To hide a column, right-click the corresponding header cell and select Hide column.

To show a hidden column:

  1. Do one of the following:
    • Right-click any of the cells in the header row and select Column List.
    • Press Ctrl+F12.

    In the list that appears, the names of hidden columns are shown struck through.

  2. Select (highlight) the column name of interest and press Space.
  3. Press Enter or Escape to close the list.

Transposing the table

The transposed table view is available. In this view, the rows and columns are interchanged.

To turn this view on or off, use the Transpose context menu command.

Enabling coding assistance for a column

You can assign a column one of the supported languages (e.g. SQL, HTML or XML): right-click the corresponding header cell, select Edit As and select the language. As a result, you get coding assistance for the selected language in all the cells of the corresponding column.

You can also assign a language to an individual cell.

Modifying cell contents

  1. To start editing a value, do one of the following:
    • Double-click the corresponding table cell.
    • Right-click the cell and select Edit Value or Edit Maximized from the context menu.
    • Select the cell and press F2 or Shift+Enter. In the latter case, the cell will be maximized.
    • 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.
  2. 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.
      DBEditValueInCell
    • Maximize the cell if you need more room for editing. To do that, press Ctrl+Shift+Alt+M, or right-click the cell and select Maximize.

      When working in a maximized cell, use Enter to start a new line and Ctrl+Enter to save the value. To restore an initial value and quit the editing mode, press Escape.

      DBEditValueInBigCell
    • Insert the contents of a text file into the cell. To do that, right-click the cell and select Load File. Then select the necessary file in the dialog that opens.
    • Edit a value in the cell as a fragment in one of the supported languages (e.g. SQL, HTML or XML). To do that, right-click the cell, select Edit As and select the language. As a result, you get coding assistance for the language you have selected.
      DBEditValueInCellAsLang

Adding and deleting rows and columns

Use the following context menu commands and shortcuts:

  • Add New Row (Alt+Insert).
  • Delete Row (Ctrl+Y). To delete more than one row at once, first, select the corresponding rows or cells in the corresponding rows.
  • Clone Row (Ctrl+D). This command creates a copy of the current row.
  • Add New Column (Shift+Alt+Insert).
  • Delete Column (Shift+Alt+Delete). To delete more than one column at once, first, select the cells in the corresponding columns.
  • Clone Column (Ctrl+Shift+Alt+D). This command creates a copy of the current column.

Copying data to the clipboard or saving them in a file

  1. Use one of the following context menu commands:
    • Copy (Ctrl+C). This command copies the data for the selected cells to the clipboard.

      If the table is shown transposed (see Transposing the table), the range of cells is copied transposed (as shown) if the Allow Transposition option is on and non-transposed (as in the original table) otherwise.

      To turn the Allow Transposition option on or off, right-click the table, point to Data Extractor: <current_format> and click Allow Transposition.

    • Dump Data | To Clipboard. This command copies the data for the whole table to the clipboard.
    • Dump Data | To File. This command saves the data for the whole table in a file. Before actually saving the data, the dialog is shown which lets you select the output format and see how your data will look in a file.
  2. If you are saving the data in a file, specify the file name and location.

See also, Changing data output format.

Changing data output format

When you copy table data to the clipboard (the Copy and Dump Data | To Clipboard commands), unless you change the format, the data are output as Tab-Separated Values (TSV).

To change the output format or to define a new format for the output:

  1. Right-click the table and point to Data Extractor: <current_format>.
  2. Do one of the following:
    • To select a different output format, click the name of the format.
    • To define a new delimiter-separated values format, or to view or modify the settings for an existing one, click Configure CSV Formats. As a result, the CSV Formats Dialog will open.

The Data tab is not visible. Why?

For the table view and associated features to be available:

  • 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".
  • Data tab is invoked by the context menu command Edit as Table.

See Also

Language and Framework-Specific Guidelines:

Last modified: 25 November 2016