Skip to main content
Glama

Visum Thinker MCP Server

MIT License
TABLE_EXPORT_WORKFLOW.md•6.78 kB
# šŸ“Š Table Export Workflow ## Overview The `project_export_visible_tables` tool exports **only the tables visible in the user's Visum GUI** to CSV files, maintaining: - āœ… Exact column order as displayed in layout - āœ… Sub-attributes (formula columns) with proper formatting - āœ… All rows for each table - āœ… UTF-8 encoding with semicolon delimiter ## How It Works ### 1. XML Layout File Parsing Global Layout files (`.lay`) are XML files containing complete definitions of all visible tables and their columns. **XML Structure (Simple Attributes):** ```xml <layout version="2"> <listLayoutItem> <caption text="Lista (Archi)"/> <listGraphicParameterLayoutItems netObjectType="LINK"/> <attributeDefinition attributeID="NO" subAttributeID1="" subAttributeID2="" subAttributeID3=""/> <attributeDefinition attributeID="LENGTH" subAttributeID1="" subAttributeID2="" subAttributeID3=""/> </listLayoutItem> </layout> ``` **XML Structure (Sub-Attributes / Formula Columns):** ```xml <attributeDefinition attributeID="VEHKMTRAVPRT_DSEG" subAttributeID1="C_CORRETTA_FERIALE" subAttributeID2="AP" subAttributeID3=""/> ``` This becomes: - Visum API: `VEHKMTRAVPRT_DSEG(C_CORRETTA_FERIALE,AP)` - CSV Header: `VEHKMTRAVPRT_DSEG_C_CORRETTA_FERIALE_AP` ### 2. Tool Workflow ``` 1. Parse .lay XML file (default: tabelle_report.lay) ↓ 2. Extract each <listLayoutItem>: - listTitle: Table name (e.g., "Lista (Archi)") - netObjectType: Collection type (e.g., "LINK", "ZONE") - attributeDefinition elements: Column names in exact order ↓ 3. For each table: - Map netObjectType → visum.Net collection - Create CSV file: {projectName}_{tableName}.csv - Export all rows with columns from XML ↓ 4. Return summary with file statistics ``` ### 3. Collection Mapping ```python collection_mapping = { 'LINK': ('Links', 'No'), 'NODE': ('Nodes', 'No'), 'ZONE': ('Zones', 'No'), 'ODPAIR': ('ODPairs', 'No'), 'LINE': ('Lines', 'Name'), 'LINEROUTE': ('LineRoutes', 'Name'), 'STOP': ('StopPoints', 'No'), 'TURN': ('Turns', 'No') } ``` ## Usage ### Basic Usage ```javascript // Export all tables from default layout (tabelle_report.lay) project_export_visible_tables({ projectId: "S000009result_1278407893" }) ``` ### Custom Layout File ```javascript // Export from specific layout file project_export_visible_tables({ projectId: "S000009result_1278407893", layoutFile: "my_custom_layout.lay" }) ``` ## Example Output ``` āœ… **Tabelle Visibili Esportate** šŸ“‚ **Progetto:** S000009result šŸŽØ **Layout:** tabelle_report.lay šŸ“ **Directory:** H:\Progetti\Visum\ šŸ“Š **Tabelle trovate nel layout:** 4 šŸ“„ **File CSV creati:** 4 šŸ“ **Totale righe esportate:** 331,750 **File esportati:** āœ… **Lista (Archi)** šŸ“„ S000009result_Lista_Archi.csv šŸ“Š 227,508 righe Ɨ 29 colonne šŸ’¾ 45,234 KB āœ… **Lista (Relazioni OD)** šŸ“„ S000009result_Lista_Relazioni_OD.csv šŸ“Š 70,225 righe Ɨ 15 colonne šŸ’¾ 12,456 KB āœ… **Lista (Linee)** šŸ“„ S000009result_Lista_Linee.csv šŸ“Š 450 righe Ɨ 22 colonne šŸ’¾ 234 KB āœ… **Lista (Percorsi di linea)** šŸ“„ S000009result_Lista_Percorsi_di_linea.csv šŸ“Š 33,567 righe Ɨ 18 colonne šŸ’¾ 8,901 KB ``` ## CSV File Format - **Delimiter:** `;` (semicolon) - **Encoding:** UTF-8 - **Headers:** First row contains column names from XML - **Data:** Exact values from Visum with same order as GUI display **Example CSV:** ```csv NO;LENGTH;VOLCAPRATIOPRT;TSYSSET;TYPENO 1;1250.5;0.85;C;1 2;890.2;0.92;C,H;2 ... ``` ## Key Features ### āœ… Advantages 1. **GUI Accuracy**: Exports exactly what user sees in Visum 2. **Column Order**: Maintains exact column order from layout 3. **Multiple Tables**: Processes all visible tables automatically 4. **Fast Parsing**: Uses native Python XML parser 5. **Error Handling**: Continues even if some tables fail ### āš ļø Limitations 1. **Layout Required**: Must have a Global Layout loaded 2. **Collection Mapping**: Only supports predefined netObjectTypes 3. **Missing Attributes**: Empty cells for unavailable attributes 4. **Large Files**: May take time for projects with millions of rows ## Interactive Workflow for AI Assistants When user requests table export: ``` 1. First, list available layouts: project_list_available_layouts({projectId: "..."}) 2. Show layouts to user and ask which to use 3. Export tables from selected layout: project_export_visible_tables({ projectId: "...", layoutFile: "user_selected.lay" }) 4. Show export summary to user ``` ## Troubleshooting ### "Layout file non trovato" **Problem:** Layout file doesn't exist in project directory **Solution:** - Use `project_list_available_layouts` to see available files - Load layout first with `project_load_global_layout` - Check filename spelling (case-sensitive) ### "Collection mapping not found" **Problem:** netObjectType not recognized (e.g., "VEHJOURNEYSECTION") **Solution:** - Add mapping to `collection_mapping` dictionary - Find correct collection name in Visum COM API documentation - Test with `visum.Net.{CollectionName}.Count` ### "No data" for table **Problem:** Collection exists but is empty (e.g., no Turns defined) **Solution:** - Normal behavior for empty collections - Check in Visum GUI if table has data - Export will skip empty tables with warning ## Technical Details ### XML Parsing ```python import xml.etree.ElementTree as ET tree = ET.parse('tabelle_report.lay') root = tree.getroot() for list_item in root.iter('listLayoutItem'): # Extract metadata common = list_item.find('.//listLayoutCommonEntries') title = common.get('listTitle') graphic = list_item.find('.//listGraphicParameterLayoutItems') net_type = graphic.get('netObjectType') # Extract columns for attr_def in list_item.iter('attributeDefinition'): column = attr_def.get('attributeID') ``` ### CSV Export ```python import csv with open(csv_file, 'w', newline='', encoding='utf-8') as f: writer = csv.writer(f, delimiter=';') writer.writerow(columns) # From XML for i in range(collection.Count): item = collection.ItemByKey(i+1) row = [item.AttValue(col) for col in columns] writer.writerow(row) ``` ## Related Tools - `project_list_available_layouts` - List available .lay files - `project_load_global_layout` - Load layout into Visum - `project_export_all_tables` - Export predefined tables (old method) ## See Also - `GLOBAL_LAYOUTS_WORKFLOW.md` - How to manage Global Layouts - `VISUM_BOT_GROUP.md` - Visum automation patterns - `CLAUDE_WORKFLOW_GUIDE.md` - Interactive AI assistant patterns

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/multiluca2020/visum-thinker-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server