a regex question
Hello There are two primary types of lines in the log: 60.191.38.xx/ 42.120.161.xx /archives/1005 I know how to write regex to match each line, but don't get the good result with one regex to match both lines. Can you help? Thanks, Maggie -- https://mail.python.org/mailman/listinfo/python-list
graphics with python
Hello Can you show me the correct way to programming with graphics? I want to take some action detection, for instance, recognize dancing etc. Thanks, Maggie -- https://mail.python.org/mailman/listinfo/python-list
paypal wholesale world cup 2010 football jersey
paypal wholesale world cup 2010 football jersey England www.supertrade06.com paypal wholesale world cup 2010 football jersey France www.supertrade06.com paypal wholesale world cup 2010 football jersey New Zealand paypal wholesale world cup 2010 football jersey Portugal www.supertrade06.com paypal wholesale www.supertrade06.comworld cup 2010 football jersey paypal wholesale www.supertrade06.comworld cup 2010 football jersey Brazil www.supertrade06.com paypal wholesale world cup 2010 football jersey England -- http://mail.python.org/mailman/listinfo/python-list
Reading in a file
hello, i have a basic script i need to implement. i need below code to read in a file and perform operation is it designed to do: #!/usr/bin/python import sys feed = sys.stdin.readlines() for temp in feed: line = temp.split() if len(line) == 3: if (line[0] == "xmax" or line[0] == "xmin"): time = line[2] print str(line[0]) + " " + str(line[1]) + " " + str(float(time)*2/3) else: print temp else: print temp i appreciate your help in advance.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Plotting wav file
On Sep 21, 3:07 pm, "Rami Chowdhury" wrote: > On Mon, 21 Sep 2009 11:58:30 -0700, Maggie wrote: > > What would be the best way to plot a small .wav file in python? If > > there are any tutorials or sample code, I would really appreciate it! > > I'm sorry, what are you hoping to plot about the .wav file? > > -- > Rami Chowdhury > "Never attribute to malice that which can be attributed to stupidity" -- > Hanlon's Razor > 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) .wav file was generated from .1D file that contained times of occurrence of a stimulus within the experiment. The y-axis is the TR and the x-axis is supposed to be the length of y. I am hoping to see plot representation of .wav file so i can align it to time series fMRI data via independent component analysis. this is the sample .1D file that was converted into the .wav file -- 2.625:2.855 46.125:46.355 92.125:92.355 150.125:150.355 179.125:179.355 239.625:239.855 304.75:304.98 321.75:321.98 382.25:382.48 396.75:396.98 408.75:408.98 515.25:515.48 549.375:549.605 609.875:610.105 621.875:622.105 691.875:692.105 740.375:740.605 752.375:752.605 825:825.23 851.5:851.73866:866.23 955.5:955.73984.5:984.731042.5:1042.73 1071.625:1071.855 1115.125:1115.355 1158.625:1158.855 1221.625:1221.855 1248.125:1248.355 1274.625:1274.855 1374.25:1374.48 1398.25:1398.48 1427.25:1427.48 1500.25:1500.48 1529.25:1529.48 1558.25:1558.48 1611.375:1611.605 1666.875:1667.105 1698.375:1698.605 1715.375:1715.605 1773.375:1773.605 1833.875:1834.105 1848.5:1848.73 1947.5:1947.73 1964.5:1964.73 1981.5:1981.73 1996:1996.23 2085.5:2085.73 2114.625:2114.855 2126.625:2126.855 2138.625:2138.855 2288.625:2288.855 2317.625:2317.855 2334.625:2334.855 2387.75:2387.98 2421.75:2421.98 2433.75:2433.98 2518.25:2518.48 2549.75:2549.98 2564.25:2564.48 thanks -- http://mail.python.org/mailman/listinfo/python-list
Plotting wav file
What would be the best way to plot a small .wav file in python? If there are any tutorials or sample code, I would really appreciate it! -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with cumulative sum
On Sep 8, 4:17 pm, MRAB wrote: > Maggie wrote: > > On Sep 8, 3:29 pm, Maggie wrote: > >> Building on the code that I posted in one of the previous posts.. I > >> need to find a cumulative sum of the file of the times in the test > >> file: > > >> here is the code i have: > > >> #!/usr/bin/python > > >> import os.path > > >> #name of output file > >> filename = "OUTPUT.txt" > > >> #open the file > >> test = open ("test.txt", "rU") > > >> #read in all the data into a list > >> readData = test.readlines() > > >> count = 0 > > >> FILE = open(filename, "w") > > >> for item in readData: > > >> count = count + 1 > >> tmp_string = str(count) + ' ' + item > >> print >> FILE, tmp_string, > > >> else: > >> print 'The loop is finito' > > >> - > > >> my test file is this > > >> 23 > >> 241 > >> 34234 > >> 83 > >> 123 > > >> and I need to find a CUMULATIVE sum (or the running sum)...what would > >> be the best way to go about that given the code i already have? > > >> thank you all! > > > --- > > > was trying to plug in the sum for the loop..but for some reason it > > doesnt want to work -- > > Read the traceback. > > > > > #!/usr/bin/python > > > import os.path > > > #name of output file > > filename = "OUTPUT.txt" > > > #open the file > > formisano = open ("test.txt", "rU") > > > #read in all the data into a list > > readData = formisano.readlines() > > > sum = 0 > > Try to avoid using the names of builtin functions and classes, in this > case 'sum'. > > > count = 0 > > > FILE = open(filename, "w") > > > for item in readData: > > > count = count + 1 > > sum = sum + (int(item) * int(item)) > > tmp_string = str(count) + ' ' + item + ' '+ sum > > You can't add a number to a string; a number is a number and a string is > a string! :-) > > tmp_string = str(count) + ' ' + item + ' '+ str(sum) > > > print >> FILE, tmp_string, > > > else: > > print 'The loop is finito' > > I saw my mistake...now it is telling me the following -- Traceback (most recent call last): File "formisano_count.py", line 22, in running_sum = running_sum + (int(item) * int(item)) ValueError: invalid literal for int() with base 10: '' .. not sure what exactly i am doing wrong! -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with cumulative sum
On Sep 8, 4:05 pm, "J. Cliff Dyer" wrote: > If I gave you a list of numbers, could you come up with a summifier > function that returns another list of numbers that are a cumulative sum? > You've got the information in place to create a file > > def summifier(nums): > """Returns a list of numbers that are the running > sum totals of nums""" > > # ??? > > list_of_numbers = [1, 24, 34, 28, 4, 1] > cumulative_sum = summifier(list_of_numbers) > assert(cumulative_sum == [1, 25, 59, 87, 91, 92]) > > If you can come up with the summifier function, you're all set. I gotta > say, though, this smells like homework. > > Cheers, > Cliff > > On Tue, 2009-09-08 at 12:29 -0700, Maggie wrote: > > Building on the code that I posted in one of the previous posts.. I > > need to find a cumulative sum of the file of the times in the test > > file: > > > here is the code i have: > > > #!/usr/bin/python > > > import os.path > > > #name of output file > > filename = "OUTPUT.txt" > > > #open the file > > test = open ("test.txt", "rU") > > > #read in all the data into a list > > readData = test.readlines() > > > count = 0 > > > FILE = open(filename, "w") > > > for item in readData: > > > count = count + 1 > > tmp_string = str(count) + ' ' + item > > print >> FILE, tmp_string, > > > else: > > print 'The loop is finito' > > > - > > > my test file is this > > > 23 > > 241 > > 34234 > > 83 > > 123 > > > and I need to find a CUMULATIVE sum (or the running sum)...what would > > be the best way to go about that given the code i already have? > > > thank you all! > > i WISH it would be homework! that way i can ask my professor and be done with it. i need this code to pre-process fMRI data for my research. and given i have never done python..i am at a loss...thanks for your help i will try this right now.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with cumulative sum
On Sep 8, 3:49 pm, Maggie wrote: > On Sep 8, 3:29 pm, Maggie wrote: > > > > > Building on the code that I posted in one of the previous posts.. I > > need to find a cumulative sum of the file of the times in the test > > file: > > > here is the code i have: > > > #!/usr/bin/python > > > import os.path > > > #name of output file > > filename = "OUTPUT.txt" > > > #open the file > > test = open ("test.txt", "rU") > > > #read in all the data into a list > > readData = test.readlines() > > > count = 0 > > > FILE = open(filename, "w") > > > for item in readData: > > > count = count + 1 > > tmp_string = str(count) + ' ' + item > > print >> FILE, tmp_string, > > > else: > > print 'The loop is finito' > > > - > > > my test file is this > > > 23 > > 241 > > 34234 > > 83 > > 123 > > > and I need to find a CUMULATIVE sum (or the running sum)...what would > > be the best way to go about that given the code i already have? > > > thank you all! > > --- > > was trying to plug in the sum for the loop..but for some reason it > doesnt want to work -- > > #!/usr/bin/python > > import os.path > > #name of output file > filename = "OUTPUT.txt" > > #open the file > formisano = open ("test.txt", "rU") > > #read in all the data into a list > readData = formisano.readlines() > > sum = 0 > count = 0 > > FILE = open(filename, "w") > > for item in readData: > > count = count + 1 > sum = sum + (int(item) * int(item)) > tmp_string = str(count) + ' ' + item + ' '+ sum > print >> FILE, tmp_string, > > else: > print 'The loop is finito' sorry...typo in code: tmp_string = str(count) + ' ' + str(sum) + ' ' + item any suggestions are welcome -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with cumulative sum
On Sep 8, 3:29 pm, Maggie wrote: > Building on the code that I posted in one of the previous posts.. I > need to find a cumulative sum of the file of the times in the test > file: > > here is the code i have: > > #!/usr/bin/python > > import os.path > > #name of output file > filename = "OUTPUT.txt" > > #open the file > test = open ("test.txt", "rU") > > #read in all the data into a list > readData = test.readlines() > > count = 0 > > FILE = open(filename, "w") > > for item in readData: > > count = count + 1 > tmp_string = str(count) + ' ' + item > print >> FILE, tmp_string, > > else: > print 'The loop is finito' > > - > > my test file is this > > 23 > 241 > 34234 > 83 > 123 > > and I need to find a CUMULATIVE sum (or the running sum)...what would > be the best way to go about that given the code i already have? > > thank you all! --- was trying to plug in the sum for the loop..but for some reason it doesnt want to work -- #!/usr/bin/python import os.path #name of output file filename = "OUTPUT.txt" #open the file formisano = open ("test.txt", "rU") #read in all the data into a list readData = formisano.readlines() sum = 0 count = 0 FILE = open(filename, "w") for item in readData: count = count + 1 sum = sum + (int(item) * int(item)) tmp_string = str(count) + ' ' + item + ''+ sum print >> FILE, tmp_string, else: print 'The loop is finito' -- http://mail.python.org/mailman/listinfo/python-list
Help with cumulative sum
Building on the code that I posted in one of the previous posts.. I need to find a cumulative sum of the file of the times in the test file: here is the code i have: #!/usr/bin/python import os.path #name of output file filename = "OUTPUT.txt" #open the file test = open ("test.txt", "rU") #read in all the data into a list readData = test.readlines() count = 0 FILE = open(filename, "w") for item in readData: count = count + 1 tmp_string = str(count) + ' ' + item print >> FILE, tmp_string, else: print 'The loop is finito' - my test file is this 23 241 34234 83 123 and I need to find a CUMULATIVE sum (or the running sum)...what would be the best way to go about that given the code i already have? thank you all! -- http://mail.python.org/mailman/listinfo/python-list
Re: Output file formatting/loop problems -- HELP?
On Sep 8, 12:35 pm, MRAB wrote: > Maggie wrote: > > On Sep 8, 11:39 am, MRAB wrote: > >> Maggie wrote: > >>> My code is supposed to enumerate each line of file (1, 2, 3...) and > >>> write the new version into the output file -- > >>> #!/usr/bin/python > >>> import os.path > >>> import csv > >>> import sys > >>> #name of output file > >>> filename = "OUTPUT.txt" > >>> #open the file > >>> test = open ("test.txt", "r") > >>> #read in all the data into a list > >>> readData = test.readlines() > >>> count = 0 > >>> FILE = open(filename, "w") > >>> for item in readData: > >> Try adding: > >> print repr(item) > > >> here to see what the lines actually look like. It might be a problem > >> with line endings. > > >>> count = count + 1 > >>> tmp_string = str(count) + ' ' + item > >>> print >> FILE, tmp_string > >>> else: > >>> print 'The loop is finito' > >>> --- > >>> here is the sample file -- > >>> 23 > >>> 123 > >>> 231 > >>> 1231 > >>> --- > >>> the output file i get looks like this: > >>> 1 23 > >>> 123 > >>> 231 > >>> 1231 > >>> -- > >>> my question is why the enumeration starts and stops at first line and > >>> doesnt go through the entire file -- > >>> (file is saved as .txt, so hypothetically no .rtf formatting that > >>> would screw up the output should be present) > >>> thanks for your help > > > great tip, thanks so much -- now this is the output i get in the > > terminal... > > > '23\r123\r231\r1231' > > > why is it so? since the file is in .txt format - there should be no > > formatting involved?... how would i fix this? > > It shows that the line endings are carriage returns '\r'. > > Line endings on Windows are '\r\n', on Unix/Linux are '\n' and on MacOS > are '\r', although recent versions of MacOS built on top of Unix. > > The easiest solution would be to open the file in universal line-ending > mode: > > test = open ("test.txt", "rU") > > This will translate any of the line endings. works beautifully now! thank you all for your input!!! -- http://mail.python.org/mailman/listinfo/python-list
Re: Output file formatting/loop problems -- HELP?
On Sep 8, 11:39 am, MRAB wrote: > Maggie wrote: > > My code is supposed to enumerate each line of file (1, 2, 3...) and > > write the new version into the output file -- > > > #!/usr/bin/python > > > import os.path > > import csv > > import sys > > > #name of output file > > filename = "OUTPUT.txt" > > > #open the file > > test = open ("test.txt", "r") > > > #read in all the data into a list > > readData = test.readlines() > > > count = 0 > > > FILE = open(filename, "w") > > > for item in readData: > > Try adding: > print repr(item) > > here to see what the lines actually look like. It might be a problem > with line endings. > > > count = count + 1 > > tmp_string = str(count) + ' ' + item > > print >> FILE, tmp_string > > > else: > > print 'The loop is finito' > > > --- > > > here is the sample file -- > > > 23 > > 123 > > 231 > > 1231 > > > --- > > > the output file i get looks like this: > > > 1 23 > > 123 > > 231 > > 1231 > > > -- > > > my question is why the enumeration starts and stops at first line and > > doesnt go through the entire file -- > > > (file is saved as .txt, so hypothetically no .rtf formatting that > > would screw up the output should be present) > > > thanks for your help > > great tip, thanks so much -- now this is the output i get in the terminal... '23\r123\r231\r1231' why is it so? since the file is in .txt format - there should be no formatting involved?... how would i fix this? -- http://mail.python.org/mailman/listinfo/python-list
Output file formatting/loop problems -- HELP?
My code is supposed to enumerate each line of file (1, 2, 3...) and write the new version into the output file -- #!/usr/bin/python import os.path import csv import sys #name of output file filename = "OUTPUT.txt" #open the file test = open ("test.txt", "r") #read in all the data into a list readData = test.readlines() count = 0 FILE = open(filename, "w") for item in readData: count = count + 1 tmp_string = str(count) + ' ' + item print >> FILE, tmp_string else: print 'The loop is finito' --- here is the sample file -- 23 123 231 1231 --- the output file i get looks like this: 1 23 123 231 1231 -- my question is why the enumeration starts and stops at first line and doesnt go through the entire file -- (file is saved as .txt, so hypothetically no .rtf formatting that would screw up the output should be present) thanks for your help -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner's python help
On Sep 6, 4:19 am, Chris Rebert wrote: > On Sun, Sep 6, 2009 at 1:10 AM, Maggie wrote: > > On Sep 6, 3:58 am, Chris Rebert wrote: > >> On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: > >> > Hi > > >> > sum = 0 > >> > for item in readData: > >> > try: > >> > sum += int(item) > >> > except ValueError: > >> > print "Oops! That was no valid number. Instead it was:", item > > >> > So you mean to say this would ignore the bad data and continue > >> > processing ? > > >> Yes. A new "try" happens every loop iteration since the "try" is > >> within the loop body. > > >> Cheers, > >> Chris > >> --http://blog.rebertia.com > > > Wow, thanks for your suggestions, Chris. Exceptions are really > > useful.. > > when i try running the script now I get a whole bunch of errors like > > this one -- > > > [jodorowskys-macbook-pro:~/desktop/formisano_replication] Jodorowsky% > > python test1.py > > That was not a valid number. Instead it was: {\rtf1\ansi > > \ansicpg1252\cocoartf949\cocoasubrtf540 > > > That was not a valid number. Instead it was: {\fonttbl\f0\fswiss > > \fcharset0 Helvetica;} > > > That was not a valid number. Instead it was: {\colortbl; > > \red255\green255\blue255;} > > > That was not a valid number. Instead it was: > > \margl1440\margr1440\vieww9000\viewh8400\viewkind0 > > > That was not a valid number. Instead it was: \pard > > \tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql > > \qnatural\pardirnatural > > > That was not a valid number. Instead it was: \f0\fs24 \cf0 32 123 231 > > 432 12} > > > - > > > why is it reading in all of the above? and how do I fix it and avoid > > it in the future? > > Your file appears to be saved in Rich Text Format (RTF) rather than > plain text (.TXT), hence Python is seeing all the formatting > gibberish. > Re-save it in the correct file format and try again. > > Cheers, > Chris > --http://blog.rebertia.com the problem is - it is saved as a .txt and not in .rtf.. which is why this error seems so bizarre..! -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner's python help
On Sep 6, 3:58 am, Chris Rebert wrote: > On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: > > Hi > > > sum = 0 > > for item in readData: > > try: > > sum += int(item) > > except ValueError: > > print "Oops! That was no valid number. Instead it was:", item > > > So you mean to say this would ignore the bad data and continue processing ? > > Yes. A new "try" happens every loop iteration since the "try" is > within the loop body. > > Cheers, > Chris > --http://blog.rebertia.com Wow, thanks for your suggestions, Chris. Exceptions are really useful.. when i try running the script now I get a whole bunch of errors like this one -- [jodorowskys-macbook-pro:~/desktop/formisano_replication] Jodorowsky% python test1.py That was not a valid number. Instead it was: {\rtf1\ansi \ansicpg1252\cocoartf949\cocoasubrtf540 That was not a valid number. Instead it was: {\fonttbl\f0\fswiss \fcharset0 Helvetica;} That was not a valid number. Instead it was: {\colortbl; \red255\green255\blue255;} That was not a valid number. Instead it was: \margl1440\margr1440\vieww9000\viewh8400\viewkind0 That was not a valid number. Instead it was: \pard \tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql \qnatural\pardirnatural That was not a valid number. Instead it was: \f0\fs24 \cf0 32 123 231 432 12} - why is it reading in all of the above? and how do I fix it and avoid it in the future? thanks so much for your help, I am learning with every post -- very exciting :) -- http://mail.python.org/mailman/listinfo/python-list
beginner's python help
code practice: test = open ("test.txt", "r") readData = test.readlines() #set up a sum sum = 0; for item in readData: sum += int(item) print sum test file looks something like this: 34 23 124 432 12 when i am trying to compile this it gives me the error: invalid literal for int() with base 10 i know a lot of people get this and it usually means that you try to cast a string into an integer and this string does not really contain a “digit”..so I am just not sure how to correct it in this case... thanks for your input -- http://mail.python.org/mailman/listinfo/python-list
Re: Running Sum script
On Sep 4, 4:37 pm, Tobiah wrote: > > in the terminal i get a very strange "permission denied" error that might > > not have anything to do with the code. I checked permissions for the file > > and they are set to "read and write" so, again, I am really not sure what > > going wrong. > > Try: > > python myfile > > Or > > chmod +x myfile > ./myfile try it where? code or terminal? thanks so much? -- http://mail.python.org/mailman/listinfo/python-list
Raw data extraction question
i have event timing stretch of code i need to alter. here is code below: -- # we start each run with one full silent trial # creating a "stub" with the duration of a full block # less the discarded acquisitions stub = block_dur - (distax * tr) feed = sys.stdin.readlines() sess = -1 for line in feed: if re.search(line != rest): time = (line + line (-1)) + (distax * tr) print time elif (line(-1) = rest): # block onsets are determined by # block number, block duration, # and the stub; 3dDeconvolve # takes care of making these # "global" time = (line) + (distax * tr) print time - my concern is that it is extracting line number and not data contained on a given line. I need it to extract data from each line (excluding lines with spaces and/or lines that contain the word "pause" or "silence"). Basically i need ONLY raw data extracted from line 1 - onward. Please let me know if you have any suggestions. Thanks! -- http://mail.python.org/mailman/listinfo/python-list