Ignore:
Timestamp:
Oct 6, 2004, 4:34:36 PM (20 years ago)
Author:
duncan
Message:

added selection of delimiter for writing .xya files and returning the title when reading .xya files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pmesh/load_mesh/loadASCII.py

    r355 r360  
    410410    if len(lines) <= 1:
    411411        raise SyntaxError
    412     lines.pop(0) #remove the first (title) line
     412    title = lines.pop(0) # the first (title) line
    413413    attLength = len(clean_line(lines[0],delimiter))-2
    414414   
     
    444444    xya_dict['pointlist'] = points
    445445    xya_dict['pointattributelist'] = pointattributes
     446    xya_dict['title'] = title
    446447    xya_dict['segmentlist'] = []
    447448    xya_dict['segmentmarkerlist'] = []
     
    454455
    455456               
    456 def export_xya_file( file_name, xya_dict, title):
     457def export_xya_file( file_name, xya_dict, title, delimiter = ','):
    457458    """
    458459    export a file, ofile, with the format
     
    476477        attlist = ""
    477478        for att in vertatts:
    478             attlist = attlist + str(att)+" "
     479            attlist = attlist + str(att)+ delimiter
     480        attlist = attlist[0:-len(delimiter)] # remove the last delimiter
    479481        attlist.strip()
    480         fd.write( str(vert[0]) + " "
    481                   + str(vert[1]) + " "
     482        fd.write( str(vert[0]) + delimiter
     483                  + str(vert[1]) + delimiter
    482484                  + attlist + "\n")
    483485    fd.close()
Note: See TracChangeset for help on using the changeset viewer.