Table vertically/horizontal for csv export

Hi,

i search for a solution, to create a material list in Grasshopper to get a list like that:


Thank´s for your support

Servus @Michael,

How is you material data structured thus far?

In the final CSV file it should look something like this:

Auftrag:ID,Position:int,Pos:int.Bezeichnung:string,Baugruppe:string, ...
,5,,Hochschrank,SE,Trägermaterial, ...

I don’t know of any GH plugins that handle CSV exporting, however the Weaverbird plugin, as well as the TT Toolbox both support Excel file handling, if that’s an option for you.

If not, you might have to resort to scripting (which by the way wouldn’t be that difficult in this case).

working with csv is really easy and fast from Python, if you don’t mind coding a little.

Here’s a simple example of script for Rhino (not GH) but you can adapt it.

#################################
### CREATE CSV FROM USER TEXT ###
#################################
import System
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import time
import math
import csv

tol = sc.doc.ModelAbsoluteTolerance

def usertext_to_csv():
    IDS = rs.GetObjects("",rs.filter.surface)
    path = r'Z:\folder\folder\folder\_export_csv\\'
    timestring = str(time.strftime("%Y.%m.%d"))#-%Hh%Mm%Ss
    csv_filename = "blockXX_"+timestring+".csv"
    csvfile = open(path+csv_filename, 'wb')
    
    csv_writer = csv.writer(csvfile, dialect='excel', delimiter='\t',quotechar='|', quoting=csv.QUOTE_MINIMAL)
    csv_writer.writerow(["Plate Name"]+["Area [m2]"]+["Width [mm]"]+["Length [mm]"])
    for id in IDS:
        plate_name = rs.ObjectName(id)
        plate_area = rs.GetUserText(id,"Area")
        plate_bb_width = rs.GetUserText(id,"Width")
        plate_bb_length = rs.GetUserText(id,"Length")
        csv_writer.writerow([str(plate_name)]+[str(plate_area)]+[str(plate_bb_width)]+[str(plate_bb_length)])
        
    csvfile.close()
        
    



if __name__ == "__main__":
    ts = time.time()
    #rs.EnableRedraw(False)
    
    usertext_to_csv()
    
    print "Elapsed time is {:.2f}".format(time.time()-ts)
2 Likes

Thank you for your answers, unfortunately i can not coding. That´s my big problem:roll_eyes:
But @ivelin.peychev thank´s for you example, i try to understand it. :slightly_smiling_face:

2 Likes