简体   繁体   中英

How to copy variables from variable explorer (Spyder python 3.5) to clipboard

Basically I want to copy multi dimensional arrays into EXCEL sheet.

If this is not possible, Atleast I should be able to export LIST from variable explorer in spyder.

I tried

`

import xlsxwriter

workbook = xlsxwriter.Workbook('arrays.xlsx')
worksheet = workbook.add_worksheet()

array = [['a1', 'a2', 'a3'],
         ['a4', 'a5', 'a6'],
         ['a7', 'a8', 'a9'],
         ['a10', 'a11', 'a12', 'a13', 'a14']]
row = 0
for col, data in enumerate(data):
    worksheet.write_column(row, col, data)
workbook.close()

` However, I couldnt copy string data which is stored as data.

Found turn around solution...

import pandas

df = pandas.DataFrame(data=MyDataAsNumpyArray)

df.to_clipboard(excel=True)

For single lists that are not multidimensional you can open the variable explorer, highlight the data (scrolling from top to bottom), and then copy (right click - select copy). If you simply copy the variable, you don't get a column, you get a string representation of the variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM