List Manipulation help

Hi
I am trying to create a Generic annotation to record sheet rev and issue dates.
I have three field that I would like to export to excell.
The Generic Annotation family.

The List
image

How I would like to get it to excell.
image

Can someone point me in the right direction for this complex list rearrangement?. Im guessing I need a to use python, but not sure where to start.

Hey,

See if this helps?

image

SheetRevisions.dyn (54.5 KB)


If you search the forum you’ll find lots of posts about this kind of thing, and perhaps different ways of approaching it.

Something I’ve noted in the graph is that when you get a sheet issed on 27/4/19 and not issued on 28/4/19 you’ll get gaps… Hopefully there are enough tips in the graph for you to fix anything for yourself.

You could do it much more efficiently in Python, but it’s more effort to see what is being outputted as you go along. Personally I’m much more familiar with the Dynamo nodes than Python methods, so would do this in nodes.

Cheers,

Mark

2 Likes

Here you go my friend, test it and let me know the results.

image

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
x = IN[0]

unique_date = []
unique_sheets = []
rows = []
unique_date.append("")
for i in x:
	if i[2] not in unique_date:
		unique_date.append(i[2])
	if i[0] not in unique_sheets:
		unique_sheets.append(i[0])

#rows = ["N/A"]*(len(unique_date)+1)

rows.append(unique_date)

for j in unique_sheets:	
	l = ["N/A"]*(len(unique_date))
	for i in x:
		if i[0] == j:		
			for k in unique_date:									
				if i[2] == k:
					l[0] = j
					index = unique_date.index(k)
					#for ind in range(1,index+1):
						#l.append("N/A")								
					l[index] = i[1]								
	rows.append(l)	
# Assign your output to the OUT variable.
OUT = rows
2 Likes

toExcl

l1 = List.SortByKey(l[0..1]<1>,l[2])["sorted list"];
l2 = List.GroupByKey(l1[1],l1[0]);
l3 = List.AddItemToFront(l2["unique keys"]<1>,l2["groups"]<1>);
l4 = List.AddItemToFront("",List.UniqueItems(List.Sort(l[2])));
l5 = List.AddItemToFront(l4,l3);
xl = DSOffice.Data.ExportExcel(".\\toExcel.xlsx", "Sheet1", 0, 0, l5, true);

Node version…

toExcel.dyn (25.8 KB)

3 Likes