Paste Grasshopper data into Excel


#1

Kind of a random question: I have a python component that outputs a list of data that I want to paste into Excel.It usually pastes in consecutive vertical cells, but is there a way to paste into consecutive horizontal cells? Excel does not allow me to paste/transpose straight from Grasshopper- I can paste, copy and then paste/transpose, but I’m looking for something more elegant. I am hoping it’s something like formatting the data so that it is in one string separated by a comma (I’ve tried this, but it does not work).


#2

Hi Lawrence,

Have you tried LeafCutter up to Google Docs (and then save down to Excel)?

It’s actually superseeded by Flux.io but LeafCutter seems simpler (I haven’t tried it (yet) but I will, so if you try, post here and let us know if it works fine).

// Rolf


#3

You could also just directly write the data to an Excel file from GHPython (using xlwt or via .NET), or simply write to a CSV file and open this in Excel.


#4

Nice!

// Rolf


#5

The reason why I want to format the data so that it pastes correctly is because it is going into an existing file. I don’t want it to paste incorrectly and overwrite existing cells. Saving the data out to the file is a longer work around than the method I am currently using (paste, copy, paste/transpose).


(Luis Fraguada) #6

If you can write out tab separated values, then you should be able to paste without jumping through any other hoops. I am almost certain I’ve done this before on Windows, but I only have Numbers available at the moment:


#7

Thanks @fraguada , that worked.

The solution is something like this:

mylist=[a,b,c,d,e]
mystring=""
for i in mylist:
    mystring+="\t"+i

In a regular panel, mystring will not appear to have tabs between each mylist item, but when you copy and paste it into an Excel file, the items will be separated. Also if you input mystring into another python script, you can split the data up by doing mystring.split("\t").