Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Excel package

Submodules

duHast.Excel.excel_io module

A number of functions Excel file operations.

duHast.Excel.excel_io.get_excel_tab_names(file_path)

Returns a list of tab names (work sheet names) in the Excel file.

Parameters:

file_path (str) – The path to the Excel file.

Returns:

A result object with the result set to a list of tab names if successful, otherwise an error message.

Return type:

Result

duHast.Excel.excel_io.save_excel_file_as_csv(file_path_excel, file_path_csv, tab_name=None)

Saves an Excel file as a CSV file.

Parameters:
  • file_path_excel (str) – The path to the Excel file.

  • file_path_csv (str) – The path to the CSV file.

  • tab_name (str) – The name of the tab ( work sheet ) in the Excel file to save as CSV. If None, the first tab is saved.

Returns:

A result object with the result set to True if successful, otherwise an error message.

Return type:

Result

duHast.Excel.excel_io.read_excel_file(file_path, excel_tab_name=None)

Reads the content of an Excel file into a 2D array.

Note: this function is rather slow, so use it with caution.

Parameters:
  • file_path (str) – The path to the Excel file.

  • excel_tab_name (str) – The name of the tab ( work sheet ) in the Excel file to read from. If None, the first tab is read.

Returns:

A result object with the result set to a 2D array if successful, otherwise an error message.

Return type:

Result

duHast.Excel.excel_io.read_excel_file_fast(file_path, excel_tab_name=None)

Reads the content of an Excel file into a 2D array.

Note: this function is faster than read_excel_file It will save the excel file as a csv file first and then read its content.

Parameters:
  • file_path (str) – The path to the Excel file.

  • excel_tab_name (str) – The name of the tab ( work sheet ) in the Excel file to read from. If None, the first tab is read.

Returns:

A result object with the result set to a 2D array if successful, otherwise an error message.

Return type:

Result

duHast.Excel.excel_io.save_csv_as_excel(file_path)

Convertes as csv to .xslx in the same directory.

Parameters:

file_path (str) – The path to the csv file.

Returns:

A result object with the result status set to true if successful, otherwise an error message.

Return type:

Result

Module contents