remove all elements in a list with a particular value

2007-05-16 Thread Lisa
I am reading in data from a text file.  I want to enter each value on
the line into a list and retain the order of the elements.  The number
of elements and spacing between them varies, but a typical line looks
like:

'   SRCPARAM   1 6.35e-07 15.00  340.00   1.10  3.0   '

Why does the following not work:

line = '   SRCPARAM   1 6.35e-07 15.00  340.00   1.10  3.0   '
li = line.split(' ')
for j,i in enumerate(li):
if i == '':
li.remove(i)

After the original split I get:
['', '', '', 'SRCPARAM', '', '', '1', '6.35e-07', '15.00', '',
'340.00', '', '', '1.10', '', '', '', '', '', '3.0', '', '', '']

And after the for loop I get:
['SRCPARAM', '1', '6.35e-07', '15.00', '340.00', '1.10', '', '', '',
'3.0', '', '', '']

It doesn't remove all of the empty elements.  Is there a better way to
split the original string?  Or a way to catch all of the empty
elements?

Thanks

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: remove all elements in a list with a particular value

2007-05-16 Thread Lisa
Great.  Thanks for your help.

-- 
http://mail.python.org/mailman/listinfo/python-list


Learning Python for a new beginner

2005-02-04 Thread Lisa Horton
I hear that Python is one of the easiest languages to learn. It is
easier than PHP or Pearl? Is it as useful as those two? I am attracted
to Python as a first language, but I just want to be sure I will be
able to use it.

Opinions, thoughts, thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Just installed python and it says python34.dll is missing

2015-10-07 Thread Lisa Twede
I tried re-downloading python and it gave me an option to repair, so I tried 
that.  But it still throws the same error.

I downloaded Python 3.5.0 for Windows.
Lisa Twede
Staff Software Developer
Products

[email protected]<mailto:[email protected]>
PHONE (818) 955-4311
FAX
[Entertainment Partners: an employee owned company]<http://www.ep.com>

Disclaimer - October 6, 2015

This email and any attachments are confidential and intended solely for 
[email protected]. If you are not a named addressee you are prohibited 
from reviewing, printing, disseminating, distributing, copying or altering this 
email or any part of it. If you have received this communication in error, 
please notify the sender of the error immediately, do not read or use the 
communication in any manner, destroy all copies, and delete it from your system 
if the communication was sent via email. Warning: Although Entertainment 
Partners has taken reasonable precautions to ensure no viruses are present in 
this email, the recipient is responsible for checking for and deleting viruses. 
Entertainment Partners does not accept responsibility for any loss or damage 
arising from the use of this email or attachments.
-- 
https://mail.python.org/mailman/listinfo/python-list


python skipping lines?

2006-11-27 Thread lisa . engblom
Hi,

I've just started programming in python, and have run into an
unexpected problem.  I am using python to pull text data from some csv
files.  I have one file that has the important identifiers (name, etc)
and other files with lots of other data.  I wrote a function that takes
the file name and identifiers as inputs, selects the data I need, and
outputs it to another file.  This function (PullData) seems to work
fine.

In the same .py file, but separate from the function, I entered used
"for line in file" to step through each line in my identifier file and
feed the identifiers into my PullData function.  It works fine for the
first entry in my identifier file, but it will not call the function
again.  It will execute lines before or after the appropriate number of
times given the number of lines in the identifier file.  i just put in
a dummy counter variable to try to figure out why it wasn't working)
... but it always skips the function call after the first line.

Any ideas of what could be the problem?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python skipping lines?

2006-11-27 Thread lisa . engblom
thats easy enough to solve

"""test text.py
for playing around with my text editing task
"""

UnitList = open('/Python25/working/FacList.txt', 'r')
RawData = open('/Python25/working/data.txt', 'r')
Output = open('/Python25/working/output.txt', 'a')

def PullHourlyData(filename, facility, unit):
for line in filename:
data = line.split('","')
CurrentFacility = data[1]
CurrentUnit = data[3]
CurrentSO2Mass = data[9]#in lb/hour
#print CurrentFacility
#print CurrentUnit

if facility == CurrentFacility and unit == CurrentUnit:

#print >> Output, '"%s", "%s", "%s"' %
(CurrentFacility, CurrentUnit, CurrentSO2Mass)
print '"%s", "%s", "%s"' % (CurrentFacility,
CurrentUnit, CurrentSO2Mass)
else:
print facility
print unit
print CurrentFacility
print CurrentUnit
print "\n"


counter = 0

for combos in UnitList:
print counter
FandU = combos.split('","')
#print combos
FacilityName = FandU[0]
UnitName = FandU[1]
#print FacilityName
#print UnitName
FacilityName = FacilityName.strip('"')
UnitName = UnitName.strip('",\n')
print FacilityName
print UnitName

PullHourlyData(RawData, FacilityName, UnitName)
counter += 1


UnitList.close()
RawData.close()
Output.close()
print "Done!"

Jordan Greenberg wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> 
> > Any ideas of what could be the problem?
> >
>
> Hard to say without seeing your code.
>
> Jordan Greenberg
> 
> -- 
> Posted via a free Usenet account from http://www.teranews.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python skipping lines?

2006-11-27 Thread lisa . engblom
Thanks, everyone for replying so promptly.  I got it to work the way I
intended, and have some ideas for how to make it much cleaner.

- Lisa

-- 
http://mail.python.org/mailman/listinfo/python-list


trouble writing results to files

2006-11-29 Thread lisa . engblom
I have two semi related questions...

First, I am trying to output a list of strings to a csv file using the
csv module.  The output file separates each letter of the string with a
comma and then puts each string on a separate line.  So the code is:

import csv
output = csv.writer(open('/Python25/working/output.csv', 'a'))
a = ["apple", "cranberry", "tart"]
for elem in range(len(a)):
output.writerow(a[elem])


... and it would write to the file:
a,p,p,l,e
c,r,a,n,b,e,r,r,y
t,a,r,t

How do I get it to write "apple", "cranberry", "tart" ?

Second, there is a significant delay (5-10 minutes) between when the
program finishes running and when the text actually appears in the
file.  Any ideas for why this happens?  It is the same for writing with
the csv module or the standard way.

thanks!
Lisa

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: trouble writing results to files

2006-11-29 Thread lisa . engblom

Roberto Bonvallet wrote:
> [EMAIL PROTECTED] wrote:
> > import csv
> > output = csv.writer(open('/Python25/working/output.csv', 'a'))
> > a = ["apple", "cranberry", "tart"]
> > for elem in range(len(a)):
> >output.writerow(a[elem])
>
> output.writerow expects a sequence as an argument.  You are passing a
> string, which is a sequence of characters.  By the way, what output are you
> expecting to get?  Do you want a file with only one line (apple,
> cranberry, tart), or each fruit in a different line?

I want it to print everything on one line and then create a new line
where it will print some more stuff.  In my real program I am iterating
and it will eventually print the list a couple hundred times.  But it
would be useful to understand how to tell it to do either.

> BTW, iterating over range(len(a)) is an anti-pattern in Python.  You should
> do it like this:
>
> for item in a:
>   output.writerow([item])

I can try that.  Is using range(len(a)) a bad solution in the sense
that its likely to create an unexpected error? Or because there is a
more efficient way to accomplish the same thing?

thanks!
Lisa

-- 
http://mail.python.org/mailman/listinfo/python-list


trouble with matplotlib

2006-12-03 Thread lisa . engblom
Hi,

I am using matplotlib with python to generate a bunch of charts.  My
code works fine for a single iteration, which creates and saves 4
different charts.  The trouble is that when I try to run it for the
entire set (about 200 items) it can run for 12 items at a time.  On the
13th, I get an error from matplotlib that says it can't access data.
However, if I start the program at the point it failed before it works
fine and will create the charts for the next 12 before failing.  I
assume that I am not closing the files properly somehow or otherwise
misallocating memory.  This is the function that creates a chart:

#create and save the figure
def CreateFigure(state, facility, unit, SO2, increment, year, P99):
size = len(SO2)

#Create Plot
figure(1, figsize=(10,8))
bar(range(1, size+2), SO2, width=0.1, color='k')
grid(True)
xlim(0,size)
ylim(0, 1.1*SO2[-1])
ylabel('SO2 [lb/hr]')
heading = ConstructFigName(state, facility, unit, increment, year)
title(heading)

#set handles
xticklines = getp(gca(), 'xticklines')
xgridlines = getp(gca(), 'xgridlines')
xticklabels = getp(gca(), 'xticklabels')
yticklines = getp(gca(), 'yticklines')

#set properties
setp(xticklines, visible=False)
setp(xgridlines, visible=False)
setp(xticklabels, visible=False)
setp(yticklines, visible=False)

axhspan(P99, P99, lw=3, ec='r', fc='r')
ax = gca()
#P99 = str(P99)
P99 = '%0.1f' % P99
text(0.01, 0.95, '99th Percentile: '+P99+' lb/hr',
transform=ax.transAxes)

figpath = ConstructFigPath(state, facility, unit, increment, year)
savefig(figpath)
close()


Can you see the problem?

thanks,
-Lisa

-- 
http://mail.python.org/mailman/listinfo/python-list


memory error with matplot

2006-12-05 Thread lisa . engblom
Hi,

I am using matplotlib with python to generate a bunch of charts.  My
code works fine for a single iteration, which creates and saves 4
different charts.  The trouble is that when I try to run it for the
entire set (about 200 items) it can run for 12 items at a time.  On the
13th, I get an error from matplotlib that says it can't access data.
However, if I start the program at the point it failed before it works
fine and will create the charts for the next 12 before failing.  I
assume that I am not closing the files properly somehow or otherwise
misallocating memory.  I tried just reimporting pylab each iteration,
but that didn't help.  This is the function that creates a chart:

#create and save the figure
def CreateFigure(state, facility, unit, SO2, increment, year, P99):
size = len(SO2)

#Create Plot
figure(1, figsize=(10,8))
bar(range(1, size+2), SO2, width=0.1, color='k')
grid(True)
xlim(0,size)
ylim(0, 1.1*SO2[-1])
ylabel('SO2 [lb/hr]')
heading = ConstructFigName(state, facility, unit, increment, year)
title(heading)

#set handles
xticklines = getp(gca(), 'xticklines')
xgridlines = getp(gca(), 'xgridlines')
xticklabels = getp(gca(), 'xticklabels')
yticklines = getp(gca(), 'yticklines')

#set properties
setp(xticklines, visible=False)
setp(xgridlines, visible=False)
setp(xticklabels, visible=False)
setp(yticklines, visible=False)

axhspan(P99, P99, lw=3, ec='r', fc='r')
ax = gca()
#P99 = str(P99)
P99 = '%0.1f' % P99
text(0.01, 0.95, '99th Percentile: '+P99+' lb/hr',
transform=ax.transAxes)

figpath = ConstructFigPath(state, facility, unit, increment, year)
savefig(figpath)
close()

Can you see the problem?

thanks,
-Lisa

-- 
http://mail.python.org/mailman/listinfo/python-list


►ENJOY free satellite tv on your pc◄

2007-08-13 Thread Lisa Jones
The New Way To Enjoy Satellite TV on your PC!

• Watch all your favorite shows on your Computer from anywhere in the
World!
• Save 1000's of $$$ over many years on cable and satellite bills
• Plus Get FREE Unlimited Downloads Movies, MP3s Music, etc !!!
• INSTANT DOWNLOAD

For More Details: http://tvonpc.freeweb7.com

-- 
http://mail.python.org/mailman/listinfo/python-list

►ENJOY free satellite tv on your pc◄

2007-08-13 Thread Lisa Jones
The New Way To Enjoy Satellite TV on your PC!

• Watch all your favorite shows on your Computer from anywhere in the
World!
• Save 1000's of $$$ over many years on cable and satellite bills
• Plus Get FREE Unlimited Downloads Movies, MP3s Music, etc !!!
• INSTANT DOWNLOAD

For More Details: http://tvonpc.freeweb7.com

-- 
http://mail.python.org/mailman/listinfo/python-list

tkinter, askopenfilename, initial directory

2008-08-07 Thread Lisa Frauens

I see there is an initial directory option in askopenfilename.  However, I want 
the initial directory to be the last directory used in a prior execution of my 
script.  Is there a way to force the askopenfilename to the previous initial 
directory easily using information somewhere (I know Windows applications 
natively do this so you don't have to navigate all the way back to directory of 
interest)?  It defaults to the current working directory. or do I have to save 
this initial directory somewhere, probably in a *.txt file,  when running my 
script the first time and then access this *.txt file, and use information as 
the initial directory option in askopenfilename, when running the script a 
subsequent time?
_
Get more from your digital life.  Find out how.
http://www.windowslive.com/default.html?ocid=TXT_TAGLM_WL_Home2_082008--
http://mail.python.org/mailman/listinfo/python-list

Init a dictionary with a empty lists

2011-02-05 Thread Lisa Fritz Barry Griffin
Hi there,

How can I do this in a one liner:

maxCountPerPhraseWordLength = {}
for i in range(1,MAX_PHRASES_LENGTH+1):
maxCountPerPhraseWordLength[i] = 0

Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list