User Profile

Collapse

Profile Sidebar

Collapse
jld730
jld730
Last Activity: Jun 7 '10, 12:10 AM
Joined: Apr 4 '07
Location: Suburban Philadelphia
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jld730
    started a topic Get XML tag values with Python

    Get XML tag values with Python

    If I wanted to get at the value in the tags for 'abstract' and 'purpose' and 'origin' in the below/end xml file, how would I got about doing that? I have tried these two ways, no luck.

    Code:
    # Import system modules
    import sys, string, os, xml.dom.minidom
    from xml.dom.minidom import parse, parseString
    
    metadata_xml_file = "C:\\Temp\\county_simp2.shp.xml"
    
    parseXMLdoc = parse(metadata_xml_file)
    ...
    See more | Go to post

  • jld730
    replied to Simple UnZip Script, help
    Thanks, that is helpful, especially for future use. For my specifc/current needs, I went with this:

    Code:
    import zipfile, os, sys
    
    test1_zip = ("C:\\Temp\\test1.zip")
    
    folder_name = sys.argv[1]
    
    output_dir = "C:\\Temp\\" + folder_name
    
    z = zipfile.ZipFile(test1_zip, 'r')
    
    zList = z.namelist()
    
    for zItem in zList:
        print "Unpacking",zItem
    ...
    See more | Go to post

    Leave a comment:


  • jld730
    started a topic Simple UnZip Script, help

    Simple UnZip Script, help

    Hi All,

    I am looking for help on this simple script to unzip/extract the contents of a zip file. This is what I have so far:

    Code:
    import zipfile, os, sys
    
    zip1 = ("C:\\Temp\\test11.zip")
    
    z = zipfile.ZipFile(zip1, 'r')
    
    zList = z.namelist()
    
    for zItem in zList:
        print "Unpacking",zItem
        zRead = z.read(zItem)
        z1File
    ...
    See more | Go to post

  • Error - "Bad file descriptor... command ID 36864..."

    Hello All,

    I have a fairly simple script that runs fine, does what it is supposed to do, but generally on the second run (after running fine again) it throws the following error:
    ***
    Traceback (most recent call last):
    File "C:\Python25\Li b\site-packages\python win\pywin\frame work\intpyapp.p y", line 341, in OnFileRun
    scriptutils.Run Script(None, None, showDlg)
    File "C:\Python25\Li b\site-packages\python win\pywin\frame work\scriptutil s.py",...
    See more | Go to post

  • jld730
    replied to Write returned XML to a .xml file
    Ahh, OK, thanks for the explanation!!...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to Write returned XML to a .xml file
    Sorry, I guess that was fairly stupid of me (forgive me -- boss has had me way over my head these days -- brain is malfunctioning) . I did this code and it works. Still not sure what 'wb' means.

    Code:
    kmlTextFile = "C:\\Temp\\scriptTEST2.kml"
    f = open(kmlTextFile, "w")
    f.write(xmldoc.toxml())
    ...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to Write returned XML to a .xml file
    I'm not sure I follow this. So with my code2, i tack this
    Code:
    f = open('filename', 'wb')
    f.write(xmldoc.toxml())
    onto the end. It executes, but where is my file saved, what is its name? I'm new to this still, but 'w', 'wb' is not familiar to me at all.

    Thanks for your response....
    See more | Go to post

    Leave a comment:


  • jld730
    started a topic Write returned XML to a .xml file

    Write returned XML to a .xml file

    In the example below, how would you write the in-memory xmldoc to a text file? In my real situation, I send a string to a web service (code 2 below) which returns XML/KML that I want to save to a local file.

    from: [HTML]http://www.faqs.org/docs/diveintopython/kgp_parse.html[/HTML]

    Code:
    >>> from xml.dom import minidom                                          
    >>> xmldoc = minidom.parse('~/diveintopython/common/py/kgp/binary.xml')
    ...
    See more | Go to post

  • jld730
    started a topic SOAP/ZSI and Python

    SOAP/ZSI and Python

    All,

    I need help concerning SOAP, Python and XML. I'm in way over my head, so if you could spoon feed me, why that would be great!

    I'm using Python and want to send a string to a web service that will output results to XML. I need to capture elements of the XML and put the info into a table. (say I send a single/simple address string to this webservice/geocode, which then returns numerous possible matches with XY values...
    See more | Go to post

  • jld730
    replied to Create Drop-down List in Excel with Python
    I figured it out myself after many hours!!! Solution is:

    Code:
    ws1 = wb.Worksheets(1)
    ws2 = wb.Worksheets(2)
    
    ws2.Cells(1,1).Value = "GREEN"
    ws2.Cells(2,1).Value = "YELLOW"
    ws2.Cells(3,1).Value = "RED"
    ws2.Cells(4,1).Value = "WHITE"
    ws2.Cells(5,1).Value = "NOT SURE"
    
    wb.Names.Add("ValidStatus", "=vl!R1C1:R5C1")
    ...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to Create Drop-down List in Excel with Python
    Add-on -->

    I finally (been looking/asking for months) ran across a method to get at the value of Excel constants for use in Pyhton scripting.

    From http://aspn.activestate.com/ASPN/Coo.../Recipe/528870 ...
    To get the value of Excel Constants such as xlEdgeLeft (7) or xlThin (2)
    type e.g. Debug.Print xlEdgeLeft in the Immediate window of the VBA editor and press enter.

    ...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to SaveAs to CSV from XLS, Excel
    I finally ran across a method to get at the value of Excel constants for use in Pyhton scripting.

    From http://aspn.activestate.com/ASPN/Coo.../Recipe/528870 ...
    To get the value of Excel Constants such as xlEdgeLeft (7) or xlThin (2)
    type e.g. Debug.Print xlEdgeLeft in the Immediate window of the VBA editor and press enter.
    See more | Go to post

    Leave a comment:


  • jld730
    started a topic Create Drop-down List in Excel with Python

    Create Drop-down List in Excel with Python

    Hello All,

    I wrote Python code to write data to an Excel worksheet1, and also add 5 status types to worksheet2 to be used to make a dropdown list for one column in worksheet1. Could someone help me with the code to do this in Python? I recorded the macro >>

    Code:
    Sub Macro2()
    '
    ' Macro2 Macro
    '
    
    '
        Sheets("Sheet2").Select
        Range("A1:A5").Select
    ...
    See more | Go to post

  • jld730
    replied to How to run a command prompt EXE?
    One last question... when I run the script in the command prompt, I have to type C:\Python24\pyt hon script.py, but you just had to type python script.py -- is there something that allows this????...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to How to run a command prompt EXE?
    Awesome, that works great, faster then GP! Thanks for your help, and feel free to contact me off list. You'd be a great resource---maybe I can be of help to you, somehow ;-)

    Final code, run from command prompt in directory where SIDs are located:
    Code:
    import glob, os
    filelist=glob.glob('*.sid')
    print filelist
    for filename in filelist:
        print filename
        os.system(r"C:\Temp\mrsidsdw.exe
    ...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to How to run a command prompt EXE?
    I have seen that output when running the EXE from the command prompt. When I add Python to the mix, no luck. The looping works (it prints each raster), and I see the command prompt flash by briefly, but no .sdw file is created.

    If I try running your [edited for me] script from the command prompt I get an error of "'python' is not recognized...'. That error along with your comment (note that I have python fully installed and...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to How to run a command prompt EXE?
    Oh, sorry... the gp module is specifc to my industry of GIS (gp = arcgisscripting .create() -- allows for geo-processing). The while loop is basically looping through all the images in a directory. The print statement simply prints out the current image file name, not important. No, mrsidsdw.exe is not in the print statement, if that is what you mean. No, I am running the python program from within Python. I was thinking that maybe i should be...
    See more | Go to post

    Leave a comment:


  • jld730
    started a topic How to run a command prompt EXE?

    How to run a command prompt EXE?

    Hi All,

    How do you run an executable that normally has to be run from the Windows Command Prompt? The EXE of interest is normally done by typing mrsidsdw.exe <dir>/sidFile.sid, while in the specific directory of the EXE. I want to get this EXE to batch process (it normally runs one at a time). In the current case, I have the EXE and the files in the same directory.

    I have tried a few things, including the below...
    See more | Go to post

  • jld730
    replied to SaveAs to CSV from XLS, Excel
    Yeah, I tried that form, too! It was one of my first bad guesses! ;-)

    MSDN code library is at > http://msdn2.microsoft.com/en-us/lib...zh(VS.80).aspx

    But anyway... yea! I finally found another posting on a GIS forum that gave me this code, which works.
    Code:
    xlApp.ActiveWorkbook.SaveAs(csvOutFile, FileFormat=24)
    I haven't found any documentation out there that states what the various codes are...
    See more | Go to post

    Leave a comment:


  • jld730
    replied to SaveAs to CSV from XLS, Excel
    Still no luck on my end of figuring this out - surely its simple. I did run across the CSV module for Python, but I don't think that is what I need. I simply need to save an XLS file as a CSV file and then move on -- no need to access the content inside the CSV file. Essentially, after save the file as a true CSV file, I execute GIS/ESRI code (I don't imagine many of you deal in this realm, but if interested, once I have the CSV file I immediately...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...