Is there any workaround? maybe with “TextQualifier Property” ?
# Schedules Exporter
# "SchedulesExporter" node from Modelical
# Batch export of schedules to CSV files. You can select the schedules with the nodes "Element Types">ViewSchedule + "All Elements of Type".
# modified by @c.poupin
# https://forum.dynamobim.com/t/exporting-schedules-to-csv-format/51791/4
"""
View.ViewName property is deprecated in Revit 2019 (remove in Revit 2020).
Replace by View.Name property
for s in schedules:
n = s.Name +".csv"
"""
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *
clr.AddReference("RevitAPIUI")
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
schedules = UnwrapElement(tolist(IN[0]))
path = IN[1]
exportTitle = IN[2]
exportColumnHeaders = IN[3]
exportHeadersFooters = IN[4]
opt = ViewScheduleExportOptions()
opt.Title = IN[2]
if not exportColumnHeaders:
opt.ColumnHeaders = 0
opt.HeadersFootersBlanks = IN[4]
i = 0
for s in schedules:
#n = s.ViewName.ToString()+".csv" # before, for Revit 2019 and before
n = s.Name +".csv" # for Revit 2020 and after
s.Export(path, n, opt)
i=i+1
OUT = i.ToString() + " schedules exported"
Hi @c.poupin great! it’s working like a charm, thank you very much, you save my day !
Now for Converting the CSV Excels format files to XLSX file I use a macro, is there any tips with python?
Have a good day
Cheers
@vishalghuge2500 - the code is working fine. However it is set to utilize a semicolon (;) as the separator to account for parts of the world where a comma j(,) is used in number formatting or as the units demarcation indicator instead of a decimal point (.).
In excel if you start a new file and got to the data tab, you can import the CSV and get a result like this:
If you want to double click and have it open correctly, you’ll either need to reconfigure excel which would cause issues with other CSVs that utilize a comma, or update line 42 of the code to be this: opt.FieldDelimiter = ','
This will utilize a comma (,) instead of a semicolon (;) and you should be all set for a double click.