473,594 Members | 2,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Script Generation, help!


I'm new to python, so I'll be at detailed as I can be.

I need to generate a script where each line is like this:

Spam=(x)
Spam=(y)
Spam=(z)

each entry being on their own line, Spam is a string of text and
x,y,and z are random numbers, I also need it to be exported to a text
file with a specified extension.... being completely NEW to python I
push in the right direction would be really helpfull!

Thanks,
Pat


Jul 18 '05 #1
2 1027
A sketch of a solution could be (untested):

yourText = "%s=(%d)" % (yourString, yourNumber)
try:
f = open(yourFileNa me, "wt")
f.write(yourTex t + "\n")
f.close()
except IOError, e:
print "There's a problem writing to file %s: %s" % (yourFileName, e)

Creating strings and numbers and putting that and the write into a loop is
yours ;-)

Kind regards
Franz GEIGER

"digital_an t2" <di**********@y ahoo.com> schrieb im Newsbeitrag
news:ma******** *************** *************** @python.org...

I'm new to python, so I'll be at detailed as I can be.

I need to generate a script where each line is like this:

Spam=(x)
Spam=(y)
Spam=(z)

each entry being on their own line, Spam is a string of text and
x,y,and z are random numbers, I also need it to be exported to a text
file with a specified extension.... being completely NEW to python I
push in the right direction would be really helpfull!

Thanks,
Pat

Jul 18 '05 #2
Some times I think my question are cryptic.

text name = a number. Try a dictionary

myDict = {} # empty defination
myDict[Spam1] = 123939392
myDict[Spam2] = 439322
myDict[Spam3] = 23233.232

Now as to storage with an extension. Thats not so tricky, it's just
that your requirement is so vague.

To save the data myDict ...
import pickle
fp = open('myfile.my specialext', 'w')
pickle.dump( myDict, fp )
fp.close()

To reload the data ...
import pickle
fp = open( 'myfile.myspeci alext', 'r')
myDict = pickle.load( fp )

Now if you have some special format the data is stored in, you may want to
visit Parser. I've not had a chance to use it, but the description is
pretty neat.

Hope this is something like what you want.

On Fri, 05 Nov 2004 07:06:15 +0000, digital_ant2 wrote:

I'm new to python, so I'll be at detailed as I can be.

I need to generate a script where each line is like this:

Spam=(x)
Spam=(y)
Spam=(z)

each entry being on their own line, Spam is a string of text and
x,y,and z are random numbers, I also need it to be exported to a text
file with a specified extension.... being completely NEW to python I
push in the right direction would be really helpfull!

Thanks,
Pat


Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3075
by: Munja | last post by:
I have PHP script running complex query and then calculating data for different conditions from received result set. Actually, it's doing the same as if I would make several queries with different conditions on same data in DB. Calculating data in PHP instead of running several queries (each query has joins on several tables with several hundreds of thousands of records) shortened page generation time, but it's still not fast enough :-(...
51
5235
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
6
2563
by: bissatch | last post by:
Hi, I am using the following code to generate images online: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6
1611
by: Brian | last post by:
Help.. We cannot get this script to work..can someone take a look at it and make suggestions? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Convert Temperature</title>
5
1901
by: Praveen | last post by:
I have script files embedded as resources in my dll. During runtime, I would like to write it out into the app dir (or a app sub-dir) and send the appropriate virtual path to the client. This makes deploying my dll much easier - just a single dll, not having to worry about deploying script files. However, the runtime doesn't seem have enough permissions to write out to the app dir (or any of it's subdir), by default. The folder where I...
11
5436
by: billmiami2 | last post by:
I recently generated a script using SQL Server 2005 for a local database that is configured as SQL Server 2000. Nevertheless, the script used the new structures and syntax (i.e., sys.objects vs. sysobjects). Is there a way that I can force SQL Server 2005 to use the old 2000 syntax? I notice that when I script objects on a remote SQL Server 2000 machine, it does use the old syntax. Bill E.
0
1647
by: Gawn | last post by:
Dear all, Greeding from Thailand. Need help for my news script. I am trying to display news which keywords match the current page keywords. I am using Dreamweaver 8 and PhpMyAdmin to manage MySQL. May I explain you what I have done. My database and data in that look like this. //* Data Base -- phpMyAdmin SQL Dump -- version 2.6.2-pl1 -- http://www.phpmyadmin.net --
0
1299
by: Fantasys | last post by:
We're seeking undiscovered unappreciated genius. E-mail me at django@kentuckyescorts.net Fantasys Enterprises the leader the USA Escort Industry is seeking developers to form the core of garage development team to help us create the next generation of Kick ass software for the our Industry. There are a lot of Escort sites and software out there but none of it created by those who KNOW this business. Members of the team will be...
4
4406
by: J. Frank Parnell | last post by:
Hi there, I have a list of links which point to e.g. thescript.php?album=somePictures1 thescript.php?album=somePictures2 This list is about 3000 links. Each album may have 500 or more pictures in it. the script looks in the specified dir, and creates thumbnails if they are not present. So, displaying a particular album often takes quite a while. I've set the proper php.ini stuff to accomodate the long script_execution's. Thats all
3
5175
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
7874
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8246
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8368
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8000
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8231
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
1476
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1205
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.