Skip to content

Read the string representation of a NumPy array from the clipboard

License

Notifications You must be signed in to change notification settings

MSeifert04/npcb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npcb

Read the string representation of a NumPy (np) array from the clipboard (cb).

For example copy the following line (for example using Ctrl + C):

[1 2 3 4 5]

Then use npcb.array to convert this string representation of a NumPy array to an actual NumPy array again:

>>> npcb.array()
array([1, 2, 3, 4, 5])

It's that simple.

It can handle simple dtypes (no masked arrays or structured arrays) and multidimension arrays like:

array([1, 2, 3, 4], dtype=uint16)

[[0.06076787 0.93465143 0.78973447]
 [0.33608162 0.71548182 0.13196038]
 [0.10906009 0.93785047 0.96137758]]

Requirements

  • setuptools (only for the installation)
  • numpy

Optional:

  • pandas
  • pyperclip

Both also provide support for reading the clipboard, maybe faster but definitely simpler than using the built-in tkinter library. If a Python is used without tkinter then one of the packages above has to be installed.

About

Read the string representation of a NumPy array from the clipboard

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages