POST
|
Amanda and I worked together on this and came up with a solution. The field user is editing the "Assemblies Count" string and the result is in the attached sample.csv file where one line represents each pole or other map point. There can be many assemblies listed on each line. The script parses that string and converts it to Milsoft .asm format (sampleAssemblies.asm) where each line lists one assembly. That file can be imported in WindMil or WindMilMap, updating the assemblies all at once. The field user has to be very careful not to alter the format of the Assemblies Count string. #-------------------------------------------------------------------------------
# Name: sampleCsvToAsm.py
# Purpose: prototype for Amanda at Flathead to read assemblies as collected during
# field survey to Milsoft ASCII .asm format
# Author: Tyler Grosshuesch
# tgrosshuesch@acecwi.com
# tdgrosshuesch@gmail.com
# Created: 2017-06-23
#-------------------------------------------------------------------------------
#Change these two paths as necessary
input = r'C:\TEMP\sample.csv'
output = r'C:\TEMP\sampleAssemblies.asm'
asmHeader = 'Map Point Name,Assembly Name,Quantity'
with open(input, 'rb') as inFile:
with open(output, 'wb') as outFile:
toWrite = asmHeader #start building the output string
content = inFile.readlines()[1:] #read the file and skip first line, https://stackoverflow.com/a/4796812
for line in content:
firstCommaAt = line.index(',')
mapPointID, assemblies = line[:firstCommaAt], line[firstCommaAt+1:].strip() #split it into pieces with the map point ID and the list of assemblies and quantities
assembliesWithQty = filter(None, assemblies.split(',')) #filter removes the nulls, split breaks them into a list of individual (qty)assembly pairs
for aQ in assembliesWithQty:
qty, assembly = aQ.replace('(', '').split(')') #get rid of the '(' character and split the qty and assembly into pieces on the ')' character
print(mapPointID + ',' + assembly + ',' + qty) #for testing
toWrite = toWrite + '\n' + mapPointID + ',' + assembly + ',' + qty #add each assembly to the output string on a new line
outFile.writelines(toWrite) #write the output string all at once to the output file) #write the output string all at once to the output file
... View more
06-26-2017
02:32 PM
|
1
|
0
|
1675
|
POST
|
Hi Amanda, If you're recording assemblies in Collector and trying to get them into WindMil, the ASCII import is the best way. The first picture that shows the format, it's a simple csv file. I typically do the import in WindMil rather than WindMilMap because it's faster. On the WM menu bar, File > Import, and work through the many options. In WMM, start an edit session, then on the menu bar, WindMilMap > Import Data and you'll get the same options you'd see in WM. You should be able to find the Milsoft WindMil ASCII format doc here, if you have the default install path: "C:\Milsoft\WindMilMap\Documents\file_layouts.pdf" If you already see the assemblies in the Map Point Editor (your first picture) but not when you look at the same feature in its attribute table (your second picture), maybe your WMM config is out of whack. I see the same thing in both places and don't have to do anything to make that happen - it's built in to WMM (my second picture). You'll want to contact Milsoft support if that's the problem. They'd be able to go through the ASCII import process with you too. Get in touch with me directly if you have any questions, I'd be happy to help another WindMilMap user! Tyler, Adams-Columbia Electric Co-op ,
... View more
06-19-2017
07:29 AM
|
0
|
1
|
1675
|
Title | Kudos | Posted |
---|---|---|
1 | 06-26-2017 02:32 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|