Paste Data

From Planimate Knowledge Base
Jump to navigation Jump to search

Copying and Pasting Behaviour

A range of cells can be selected and copied either using the "Copy" context menu option or Ctrl-C.

For pasting, the context menu has options for Paste Over, Paste Insert and Paste Append. These all operate from the selected cell (the column for Paste Append) or top left of a selected region if the selected cell is within it. Ctrl-V acs as the Paste Over.

Paste Insert inserts rows at the target row for the pasted data. Paste Append adds rows to the bottom of the table. These two options are not available if the table option "User Cannot Add/Delete Rows" is set, only Paste Over existing cells is possible.

Paste Over ignores columns past the last table column. If you are creating a table in Planimate you could use the "Import From Clipboard" option in the Table Editor File Menu. This is a data import tool that can create table columns and is not being discussed here.

Paste Over automatically appends rows if the pasted data extends paste the last row in the table unless the "User Cannot Add/Delete Rows" is set for the table.

Any columns with the "Protect From Edits" column option set are silently skipped during a paste, retaining their existing value. Newly added rows get the clear value for such columns. If all columns are set to "Protect From Edits" then a Paste OVer is effectively ignored.

Copying and pasting honours views with custom column formats/arrangements and row filters. You can paste over row filtered data but Planimate will not insert or append rows whilst there is a row filt

Memory vs Clipboard Paste

Data in the table editor and table views can be copy/pasted within Planimate, between instances of Planimate with different models and between Planimate and other applications such as spreadsheets.

When data is copy/pasted within an instance of Planimate, an "in-memory copy" is made, generally the underlying data is copied exactly as represented. This preserves precision even for display formats that truncate the displayed data, do not show years etc.

In cases where another application is active then Planimate is selected, the clipboard is used for pasting. It might well be the same data that was previously copied in that Planimate instance, eg:

  • you copy some data from a table
  • you switch to another program
  • you switch back to Planimate and paste

Copy/pasting via the clipboard is especially useful when a user pastes data from a spreadsheet. Some of Planimate's display formats are not clipboard friendly as they may hide seconds, minutes, the date or even the year, making their textual form only useful for reports, not actually useable date data input.

For a developer, copy/pasting such data is not a problem so long as you copy and paste within an instance of Planimate without switching to another application in between.

Special Paste Handling

Scaled Units

To keep consistent with the clipboard, pasting between scaled columns such as "Time Hours (scaled)", "Time Minutes (scaled)" and other unscaled columns such as "Units" always copies the numbers as displayed, even when it is a memory copy.

Text Columns

In-memory pasting from a non text column (values, times, labels) into a "Text" formatted column will paste the formatted original cell as text. This is particularly useful for converting labels into pure text.

In-memory pasting from a "Text" formatted column into any other format will attempt to interpret the text as the destination format, be it numbers, dates or labels - ie: you can use this to convert text into labels.

The above two cases are consistent with what would happen via the clipboard since there is no distinction between text and no text cells apart from enclosing quotes which are removed upon paste.

Pasting Into Dates

Planimate is quite generous when pasting into date formatted columns, if the format of the column fails to parse pasted text, Planimate will try each of the main classes of calendar time format that it supports, including the default operating system data format.

However if dealing with purely numerical US month/date/year data, it is strongly advised that the desination column be correctly formatted for such US dates as the defaults for date/month/year could easily misinterpret such data. Using named months will avoid this problem.

If a cell does not parse as a date its logged as an error and the paste continues.

Units and Times

Planimate first tries the format of the column to parse pasted data. If this fails, it will use simple heuristics (the "autoparser") to look for money, commas and hh:mm / hh:mm:ss type times and paste the value into the cell, with times being converted to seconds as is standard for most time formats (apart from the scaled ones mentioned above). If the autoparser fails, the cell is logged as an error.

Labels

Label formatted columns automatically add new labels if the user can add labels into that column, otherwise they are logged as errors.

Error Handling

Paste errors are not reported cell by cell, a count is kept and they are collected into a log file.

If the table view has been configured to send a Paste Broadcast and the model is not stopped, a paste always sends the selected broadcast with the "_Pasted" attributes described below.

If there is no broadcast set or the model is stopped, and the user has the ability to edit (ie: not a PBA), then if errors occur, a dialog reports how many and offers the option to show the log file. This will be opened in the default text editor, typically notepad and is intended to assist developers.

Paste broadcast attributes:

  • "_dataid" : table data object ID if set, or zero
  • "_panel"  : panel ID of the table's panel
  • "_errorcount" : how many errors occured.

If _errorcount is > 0 then s.LastErrorFileNamePath is the error log filename. A trivial handler might just show this file in notepad regardless of the table (given the user has just pasted into it). This file will persist in TEMP, the modeller can delete it if desired.

Error Log File Format

The error log file contains 4 columns, these are:

  • row iof actual table celll
  • column of actual table cell
  • error code, from the l._import_errors label list
  • the text which caused the problem, in quotes

Routine operation PasteIntoView

Combined with a Ctrl-V key handler, this used to be the way that applications supported pasting into a table. This is still supported however:

  • do not expect to receive the Ctrl-V key broadcast, this is no longer supported
  • The error log file described above is written on errors however no return result is set, instead you receive a new error code l._import_errors[Logged Errors] which indicates that at least one error occured.
  • Unless the option IgnoreErrors was included to the operation, the import will stop after the first error and you get the code back for the actual error.