Just wanted to add a solution that does not care about how you list is structured, but will work on any depth like follows:
Credit to @kennyb6 as I’ve borrowed a little of his code from this post: Change list structure to match another list structure
Implementing that in @mellouze adaption of @Thomas_Mahon script it would look something like this, but it could probably be modified so that you keep your list structure in the output
#Copyright 2016. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.co.uk
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.co.uk
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
#
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
result = []
x = []
def rec(_lists):
for _list in _lists:
if isinstance(_list,list):
c = rec(_list)
else:
x.append(_list)
return x
schedules = rec(IN[0])
for i in range(len(schedules)):
schedule = UnwrapElement(schedules[i])
# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)
#count the number of rows and columns in the schedule
table = schedule.GetTableData().GetSectionData(SectionType.Body)
nRows = table.NumberOfRows
nColumns = table.NumberOfColumns
#Collect all of data from the schedule
dataListRow = []
for row in range(nRows): #Iterate through the rows. The second row is always a blank space
dataListColumn = []
for column in range(nColumns): #Iterate through the columns
dataListColumn.Add( TableView.GetCellText(schedule, SectionType.Body, row, column) )
dataListRow.Add( dataListColumn );
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()
result.append(dataListRow)
OUT = result;