PyCharm 3.4.0 Web Help

Overview

For working with comma-separated values (CSV) and tab-separated values (TSV) text files, PyCharm 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.)

CSVTextView CSVTableView

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.

CSVTableViewMenu

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

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 from the context menu.
    • Click the cell and press F2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt+EnterF2 or Alt EnterF2 or Alt EnterF2 or Alt Enter.
  2. Now you can edit the value right in the cell, or open a dialog which gives you more room for editing and additional options. Do one of the following:
    • Modify the value right in the cell. To save the changes, press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter or click a different cell. To restore an initial value and quit the editing mode, press EscapeEscapeEscapeEscapeEscape, Escape or Ctrl+GEscapeEscapeEscapeEscapeEscapeEscape.
    • Click browseButton or press Shift+EnterShift+EnterShift+EnterShift+EnterShift+EnterShift+EnterShift+EnterShift+EnterShift EnterShift EnterShift Enter. In the dialog that opens, you can:
      • Make the necessary edits in the upper area.
      • Replace the current value with null (click Set NULL).
Adding a row
  1. 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+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter.
  2. To enter values into the cells, use the same procedure as in the case of Modifying cell contents.
Deleting rows
  1. 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.

  2. Press Ctrl+YCtrl+YCtrl+YCtrl+YCtrl+YCtrl+Shift+LCtrl+ECtrl+DCommand BackspaceCommand YCommand D or DeleteDeleteDeleteDeleteDelete or Ctrl+DDeleteDeleteDeleteDelete, Backspace or Command BackspaceDelete, Backspace or Command BackspaceDelete, Backspace or Command Backspace.
  3. Confirm you intention to delete the selected row or rows.
Copying the table to the clipboard or saving the table in a file
  1. Right-click the table and select Copy All To Clipboard or Save All To File from the context menu.
  2. If you are saving the table in a file, specify the file name and location.
Changing the table output format

Several output formats are available for copying tables to the clipboard or saving them in files. (The output formats, in PyCharm are called data extractors.)

When using the Copy All To Clipboard or Save All To File command, the output format (the extractor) which is currently active is used.

To make a different extractor active or to create a new extractor:

  1. Right-click the table and point to Data Extractor: <extractor_name> in the context menu.
  2. 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.
Sorting data

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.

See also, Using the structure view to sort the data, and hide and show the columns.

Hiding columns

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

See also, Using the structure view to sort the data, and hide and show the columns.

Using the structure view to sort the data, and hide and show the columns

When working with the 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 View | Tool Windows | Structure in the main menu.
  • Click Structure on the left-hand tool window bar.
  • Press Alt+7Alt+7Alt+7Alt+7Alt+7Alt+7Ctrl+7 or Alt+7Alt+7Command 7Command 7Command 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+F12Ctrl+F12Ctrl+0Ctrl+F12Ctrl+F12Ctrl+F12Ctrl+F12 or Ctrl+Shift+F12Ctrl+F3 or Ctrl+OCommand F12Command F12Command O.

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+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift Alt UpShift Alt UpShift Alt Up. (In the tool window, you can, alternatively, select Sort | Ascending from the context menu.)
  • To sort the data in the descending order, press Shift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift Alt DownShift Alt DownShift Alt Down. (In the tool window, alternatively, Sort | Descending.)
  • To cancel sorting by this column, press Ctrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceShift Alt Command BackspaceShift Alt Command BackspaceShift Alt Command Backspace. (In the tool window, alternatively, Sort | Unsorted.)
  • To hide the column (or show a hidden column), press SpaceSpaceSpaceSpaceSpaceSpaceSpaceSpaceSpaceSpaceSpace. (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.)

    CSVStructureView

The shortcuts for sorting table data (Shift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift+Alt+UpShift Alt UpShift Alt UpShift Alt Up, Shift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift+Alt+DownShift Alt DownShift Alt DownShift Alt Down and Ctrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceCtrl+Shift+Alt+BackspaceShift Alt Command BackspaceShift Alt Command BackspaceShift Alt Command Backspace) can be used even without opening the structure view.

See also, Sorting data and Hiding columns.

The Data tab doesn't show up. Why?
  • For the table view and associated features to be available, the Database Support 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 used must be associated with the text file type.
  • The number of lines in a TSV or CSV file is insufficient.