How to use sheets method in pyatom

Best Python code snippet using pyatom_python

script.py

Source:script.py Github

copy

Full Screen

...84 except:85 continue86 sorted_keys = sorted(ordered_sheets_dict.keys())87 return [ordered_sheets_dict[x] for x in sorted_keys]88 def _get_ordered_schedule_sheets(self):89 schedule_view = self.selected_schedule90 cl_sheets = FilteredElementCollector(doc, schedule_view.Id)91 sheets = cl_sheets.OfClass(clr.GetClrType(ViewSheet)).WhereElementIsNotElementType().ToElements()92 return self._order_sheets_by_schedule_data(schedule_view, sheets)93 def _is_sheet_index(self, schedule_view):94 return self.sheet_cat_id == schedule_view.Definition.CategoryId95 def _get_sheet_index_list(self):96 cl_schedules = FilteredElementCollector(doc)97 schedules = cl_schedules.OfClass(clr.GetClrType(ViewSchedule)).WhereElementIsNotElementType().ToElements()98 return [sched for sched in schedules if self._is_sheet_index(sched)]99 def _print_combined_sheets_in_order(self):100 # todo: Revit does not follow the order of sheets as set by ViewSet101 print_mgr = doc.PrintManager102 print_mgr.PrintRange = PrintRange.Select103 viewsheet_settings = print_mgr.ViewSheetSetting104 sheet_set = ViewSet()105 for sheet in self.sheets_lb.ItemsSource:106 sheet_set.Insert(sheet.revit_sheet)107 # Collect existing sheet sets108 cl = FilteredElementCollector(doc)109 viewsheetsets = cl.OfClass(clr.GetClrType(ViewSheetSet)).WhereElementIsNotElementType().ToElements()110 all_viewsheetsets = {vss.Name: vss for vss in viewsheetsets}111 sheetsetname = 'OrderedPrintSet'112 with Transaction(doc, 'Update Ordered Print Set') as t:113 t.Start()114 # Delete existing matching sheet set115 if sheetsetname in all_viewsheetsets:116 viewsheet_settings.CurrentViewSheetSet = all_viewsheetsets[sheetsetname]117 viewsheet_settings.Delete()118 viewsheet_settings.CurrentViewSheetSet.Views = sheet_set119 viewsheet_settings.SaveAs(sheetsetname)120 t.Commit()121 print_mgr.PrintToFile = True122 print_mgr.CombinedFile = True123 print_mgr.PrintToFileName = op.join(r'C:', 'Ordered Sheet Set.pdf')124 print_mgr.SubmitPrint()125 def _print_sheets_in_order(self):126 print_mgr = doc.PrintManager127 print_mgr.PrintToFile = True128 # print_mgr.CombinedFile = False129 print_mgr.PrintRange = PrintRange.Current130 for sheet in self.sheets_lb.ItemsSource:131 output_fname = cleanup_filename('{:05} {} - {}.pdf'.format(sheet.print_index,132 sheet.number,133 sheet.name))134 print_mgr.PrintToFileName = op.join(r'C:', output_fname)135 if sheet.printable:136 print_mgr.SubmitPrint(sheet.revit_sheet)137 def _update_print_indices(self, sheet_list):138 for idx, sheet in enumerate(sheet_list):139 sheet.print_index = idx140 # noinspection PyUnusedLocal141 # noinspection PyMethodMayBeStatic142 def selection_changed(self, sender, args):143 if self.selected_schedule:144 sheet_list = [ViewSheetListItem(x) for x in self._get_ordered_schedule_sheets()]145 # reverse sheet if reverse is set146 if self.reverse_print:147 sheet_list.reverse()148 if not self.show_placeholders:149 self.indexspace_cb.IsEnabled = True150 # update print indices with placeholder sheets151 self._update_print_indices(sheet_list)152 # remove placeholders if requested153 printable_sheets = []154 for sheet in sheet_list:155 if sheet.printable:156 printable_sheets.append(sheet)157 # update print indices without placeholder sheets158 if not self.include_placeholders:159 self._update_print_indices(printable_sheets)160 self.sheets_lb.ItemsSource = printable_sheets161 else:162 self.indexspace_cb.IsChecked = True163 self.indexspace_cb.IsEnabled = False164 # update print indices165 self._update_print_indices(sheet_list)166 # Show all sheets167 self.sheets_lb.ItemsSource = sheet_list168 # noinspection PyUnusedLocal169 # noinspection PyMethodMayBeStatic170 def print_sheets(self, sender, args):171 if self.sheets_lb.ItemsSource:172 self.Close()173 if self.combine_print:174 self._print_combined_sheets_in_order()175 else:176 self._print_sheets_in_order()177 # noinspection PyUnusedLocal178 # noinspection PyMethodMayBeStatic179 def handle_url_click(self, sender, args):180 open_url('https://github.com/McCulloughRT/PrintFromIndex')181 # noinspection PyUnusedLocal182 # noinspection PyMethodMayBeStatic183 def preview_mouse_down(self, sender, args):184 if isinstance(sender, ListViewItem):...

Full Screen

Full Screen

run_tests2.py

Source:run_tests2.py Github

copy

Full Screen

2# export data sheets from xlsx to csv3from openpyxl import load_workbook4import csv5from os import sys6def get_all_sheets(excel_file):7 sheets = []8 workbook = load_workbook(excel_file,read_only=True,data_only=True)9 all_worksheets = workbook.sheetnames10 for worksheet_name in all_worksheets:11 sheets.append(worksheet_name)12 return sheets13get_all_sheets('excel_to_convert.xlsx')14def csv_from_excel(excel_file, sheets):15 workbook = load_workbook(excel_file, data_only=True)16 for worksheet_name in sheets:17 print("Export " + worksheet_name + " ...")18 try:19 worksheet = workbook.get_sheet_by_name(worksheet_name)20 print(worksheet)21 except KeyError:22 print("Could not find " + worksheet_name)23 sys.exit(1)24 your_csv_file = open(''.join([worksheet_name, '.csv']), 'w')25 wx = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)26 for row in worksheet.iter_rows():27 lrow = []28 for cell in row:29 lrow.append(cell.value)30 wx.writerow(lrow)31 print(" ... done")32 your_csv_file.close()33#get_all_sheets('excel_to_convert.xlsx')34#csv_from_excel('excel_to_convert.xlsx',get_all_sheets('excel_to_convert.xlsx'))35if not 2 <= len(sys.argv) <= 3:36 print("Call with " + sys.argv[0] + " <xlxs file> [comma separated list of sheets to export]")37 sys.exit(1)38else:39 sheets = []40 if len(sys.argv) == 3:41 sheets = list(sys.argv[2].split(','))42 else:43 sheets = get_all_sheets(sys.argv[1])44 assert(sheets != None and len(sheets) > 0)45 csv_from_excel(sys.argv[1], sheets)46'''47from openpyxl import load_workbook48import csv49from os import sys50def get_all_sheets(excel_file):51 sheets = []52 workbook = load_workbook(excel_file, read_only=True, data_only=True)53 all_worksheets = workbook.get_sheet_names54 for worksheet_name in all_worksheets:55 sheets.append(worksheet_name)56 #print(f'{sheets} this are the files')57 return sheets58def csv_from_excel(excel_file, sheets):59 workbook = load_workbook(excel_file, data_only=True)60 for worksheet_name in sheets:61 print("Export " + worksheet_name + " ...")62 try:63 worksheet = workbook.get_sheet_by_name(worksheet_name)64 except KeyError:65 print("Could not find " + worksheet_name)66 sys.exit(1)67 your_csv_file = open(''.join([worksheet_name, '.csv']), 'wb')68 wr = csv.writer(your_csv_file, quoting=csv.QUOTE_ALL)69 for row in worksheet.iter_rows():70 lrow = []71 for cell in row:72 lrow.append(cell.value)73 wr.writerow(lrow)74 print(" ... done")75 your_csv_file.close()76#get_all_sheets(excel_to_convert.xslx)77if not 2 <= len(sys.argv) <= 3:78 print("Call with " + sys.argv[0] + " <xlxs file> [comma separated list of sheets to export]")79 sys.exit(1)80else:81 sheets = []82 if len(sys.argv) == 3:83 sheets = list(sys.argv[2].split(','))84 else:85 sheets = get_all_sheets(sys.argv[1])86 assert(sheets != None and len(sheets) > 0)87 csv_from_excel(sys.argv[1], sheets)88'''89'''90use_iterators91read_only92d=[3,4,5,6,7,8,9]93for i in range(len(d)):94 print(i)95x=2.000096n=1097c= n**x98print(str(c))99#!/usr/bin/env python...

Full Screen

Full Screen

excelsort.py

Source:excelsort.py Github

copy

Full Screen

...35 sheets[ssp] = pd.DataFrame({'YEARS':YEARS})36 37 # add in data to this ssp sheet38 sheets[ssp][model] = pd.Series(data)39def create_sheets():40 for FOLDER in FOLDERS:41 print("======= Starting folder:", FOLDER, "=======")42 #? determine what the S43 if FOLDER == "OBSERVATION-files/": SSPS = ('W5E5v1.0',)44 else: SSPS = ('ssp126','ssp370', 'ssp585')45 for VAR in VARIABLES:46 #? determine the TYPE:47 if VAR == 'tasmin': TYPE = 'MIN'48 else: TYPE = 'MAX'49 for SSP in SSPS:50 model = FOLDER.split('-')[0] 51 fname = model + '-' + VAR + '-' + SSP52 SAVE_PATH = './visuals/' + model + '-visuals/' + fname53 54 # get this data array55 data = extract_per_year(model, VAR, SSP, TYPE)56 #? DIFFERENT YEARS FOR OBSERVATIONS57 if model == 'OBSERVATION': YEARS = [yr for yr in range(1979, 2017)]58 print(f">>> model {model}, var {VAR}, ssp {SSP}, data size: {len(data)}")59 add_data(model, VAR, SSP, data)60def write_var_to_excel(sheets:dict):61 filename = './excelsheets/'62 if sheets is pr_sheets: filename += 'pr_data.xlsx'63 elif sheets is tas_sheets: filename += 'tas_data.xlsx'64 elif sheets is tasmax_sheets: filename += 'tasmax_data.xlsx'65 else: filename += 'tasmin_data.xlsx' # sheets is tasmin_sheets66 writer = pd.ExcelWriter(filename, engine='xlsxwriter')67 # write each dataframe to a different worksheet68 for ssp in sheets:69 sheets[ssp].to_excel(writer, sheet_name=ssp)70 writer.save()71def write_sheets_to_excel():72 for workbook in workbooks:73 write_var_to_excel(workbook)74 75create_sheets()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful