473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get a value from another python script

Hi,

i'm trying to get a value from a Python script called getValue and use this value to select the correct symbology layer for a ArcGIS map.

This is the first code:
Expand|Select|Wrap|Line Numbers
  1. import arcgisscripting
  2. gp = arcgisscripting.create(9.3)
  3. intable = gp.GetParameterAsText(0)
  4. infield = gp.GetParametersAsText(1)
  5.  
  6. # open cursor
  7. rows = gp.searchcursor(intable)
  8. row = rows.next()
  9. fval = row.GetValue(infield)
  10. gp.SetParameterAsText(2, str(fval))
  11.  
and this is the second one.

Expand|Select|Wrap|Line Numbers
  1. import sys, string, os, arcgisscripting
  2.  
  3. gp = arcgisscripting.create()
  4. gp.AddToolbox("filepath/Data Management Tools.tbx")
  5. gp.AddToolbox("filepath/Mark Toolbox.tbx")
  6.  
  7. String = ? #This has to be the value from the GetValue script
  8. VCI_Laag = "filepath\\Symbology_Files\\"+String +".lyr"
  9. Grondsoorten_Verzadigd = "Grondsoorten_Verzadigd"
  10.  
  11. gp.ApplySymbologyFromLayer_management(Grondsoorten_Verzadigd, VCI_Laag)
The Dutch words are filenames.

Could anyone help me?
Nov 16 '10 #1
1 3161
bvdet
2,851 Expert Mod 2GB
You could write the information to a disk file in the first script and read the data from the disk file in the second script. I will assume you will consistently be in a certain working directory, otherwise you would need the include the path in the file name.

First script:
Expand|Select|Wrap|Line Numbers
  1. file_name = "data.txt"
  2. fileObj = open(file_name, 'w')
  3. fileObj.write(str(favl))
  4. fileObj.close()
Second script:
Expand|Select|Wrap|Line Numbers
  1. fval = open(file_name).read()
Nov 16 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tubby Tudor | last post by:
What is the best way to call one python script from within another python script? For example: one.py finishes succesfully and calls two.py which finishes OK and then calls three.py Thanks...
1
by: Steve | last post by:
Hi, I've written a small cgi python script that collects feedback from a webform. I need to pass the values to another python script.. how do I do this? Is this even possible? Thanks Steve
1
by: sarmin kho | last post by:
Hi Python Guru, I ve created a GUI using Boa constructor and am now trying to execute a python script when pressing a button on the GUI. So, there will then be two main threads running (the GUI...
3
by: olaufr | last post by:
Hi, I need to call a python script, with command line arguments (it is an autonomous script with a __main__), from within another python script. Can I use exec() or execfile() for this? How to...
2
by: KraftDiner | last post by:
I have a class that is defined in a file called MyClass.py How do I use that class in another python script.. import MyClass ? (Does it need to be in a specific location?)
11
by: volcano | last post by:
Hello, folks! A trivial question - I have a working Python script that I have to invoke from C++ code. No fancy stuff - just run the whole script with its parameters. No callbacks, no signalling -...
17
by: somialis | last post by:
I have a test environment in python. it is executed by the following command on the command prompt. 1) First i have to go to the dir where the .py file is 2) then i simply execute python...
2
by: Ulysse | last post by:
Hello, I've installed Python 2.5 on my WRT54G Linksys Router. On this router a script is executed. This script write a little Pickle database in the router memory. I would like to write...
2
by: Alexandru Mosoi | last post by:
how do I execute another python script under a different process? I want the script to be run using the same interpretoer as the one running current script. I tried using os.execlp but I don't know...
2
by: gintrado | last post by:
I am very new to Python I'm trying to run a python script from within another python script. I can run the script from a unix command line by typing: nohup python script.py password >...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.