Re: Parsing data from text file to python

2015-08-09 Thread Laura Creighton
In a message of Mon, 10 Aug 2015 08:55:10 +0530, OmPs writes: >I have built a contact form which sends me email for every user >registration My question is more related to parsing some text data into csv >format. Your contact form should be able to produce csv files for you, rather than producing p

Re: Parsing Data

2009-06-01 Thread babypython
Thanks a lot. That works for me. Chris Rebert-6 wrote: > > On Mon, Jun 1, 2009 at 11:45 AM, babypython <2myemailaddr...@gmail.com> > wrote: >> >> I am trying to parse through  this data for analysis. I am new to python >> and >> wondering what would be the quickest way to extract the data from

Re: Parsing Data

2009-06-01 Thread Chris Rebert
On Mon, Jun 1, 2009 at 11:45 AM, babypython <2myemailaddr...@gmail.com> wrote: > > I am trying to parse through  this data for analysis. I am new to python and > wondering what would be the quickest way to extract the data from this file. > The data files consists of comments (starting with ! and #

Re: Parsing data from pyserial, an (inefficient) solution

2006-12-04 Thread Grant Edwards
On 2006-12-04, Giovanni Bajo <[EMAIL PROTECTED]> wrote: [...] >> This should result in complete packets (from the "M" to a "\r") > > Oh well. readline(eol="\r") will do that much better. Yup. Using readline() has been suggested several times. It sure seems like the obvious solution to me as w

Re: Parsing data from pyserial

2006-12-04 Thread Grant Edwards
On 2006-12-04, John Machin <[EMAIL PROTECTED]> wrote: > Try reading previous posts. The OP reported that to be returned from > the cam, based on print forty_bytes, not print repr(forty_bytes). I > think everybody (including possibly even the OP) is willing to believe > that the cam is *generating*

Re: Parsing data from pyserial, an (inefficient) solution

2006-12-04 Thread Giovanni Bajo
Dennis Lee Bieber wrote: > >> The really sad thing is that I get a perfectly constructed >> packet from the reading variable, and that gets butchered when I >> try to slice it up to pick out individual elements. Since >> pyserial doesn’t do anything to rearrange the data, then the >> CMUcam must d

Re: Parsing data from pyserial

2006-12-03 Thread John Machin
Si Ballenger wrote: > On 3 Dec 2006 17:33:59 -0800, "John Machin" > <[EMAIL PROTECTED]> wrote: > > >In any case, I wouldn't call that "the appropriate data is being > >received" -- looks like chunks missing to me. > > Well, below is the posted expected return data format from the > cam and below t

Re: Parsing data from pyserial, an (inefficient) solution

2006-12-03 Thread John Machin
Lone Wolf wrote: Your code has a problem when the first character of reading is 'M': you will miss the full packet and pick up a fragment. The length test that you are doing to reject the fragment is a kludge. If the average length of a packet is say 25, then you are throwing away 4% of all packet

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On 3 Dec 2006 17:33:59 -0800, "John Machin" <[EMAIL PROTECTED]> wrote: >In any case, I wouldn't call that "the appropriate data is being >received" -- looks like chunks missing to me. Well, below is the posted expected return data format from the cam and below that is what has been reported to be

Re: Parsing data from pyserial

2006-12-03 Thread John Machin
Si Ballenger wrote: > > Per what was posted (below), it appears that the the appropriate > data is being received. [snip] > > Here is an example output: > > M 37 79 3 4 59 124 86 25 > ['59', '123', '87', '25', 'M', '37', '79', '3', '4', '59', > '124', '86', '25', 'M > '] > M 38 77 3 2 59 124 86 25

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On Sun, 03 Dec 2006 18:44:07 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> wrote: > In my dealing with serial gizmos I have to put a delay between the request sent to the gizmo and the reading of the serial input buffer for returned

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, John Machin <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > >> When something odd seems to be happening with strings, always >> print `whatever` rather than whatever >> > >:-) > > Unholy perlism, Batman! OK, make that "print repr(whatever)". :) -- Grant Edwards

Re: Parsing data from pyserial

2006-12-03 Thread Fredrik Lundh
Si Ballenger wrote: > I would think a time delay would be needed between the below two > lines in the code if he expects to get a useable data string back > from the gizmo for the command sent to it. > > ser.write("TC 016 240 100 240 016 240\r\n") > reading = ser.read(40) why's that? if t

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> wrote: >>> In my dealing with serial gizmos I have to put a delay between >>> the request sent to the gizmo and the reading of the serial input >>> buffer for returned data. Serial ports and gizmos need some time >>> to do their thing. >> >>I doubt t

Re: Parsing data from pyserial

2006-12-03 Thread John Machin
Grant Edwards wrote: > When something odd seems to be happening with strings, always > print `whatever` rather than whatever > :-) Unholy perlism, Batman! For the benefit of gentle readers who are newish and might not have seen the ` character in Python code outside a string literal, or for tho

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On Sun, 03 Dec 2006 16:52:33 -, Grant Edwards <[EMAIL PROTECTED]> wrote: >On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> wrote: > >> In my dealing with serial gizmos I have to put a delay between >> the request sent to the gizmo and the reading of the serial input >> buffer for returned data.

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, Si Ballenger <[EMAIL PROTECTED]> wrote: > In my dealing with serial gizmos I have to put a delay between > the request sent to the gizmo and the reading of the serial input > buffer for returned data. Serial ports and gizmos need some time > to do their thing. I doubt that's the is

Re: Parsing data from pyserial

2006-12-03 Thread Si Ballenger
On Sat, 2 Dec 2006 23:02:06 -0500, Lone Wolf <[EMAIL PROTECTED]> wrote: >I'm trying to get data through my serial port from a CMUcam. >This gizmo tracks a color and returns a packet of data. The >packet has nine data points (well, really eight since the first >point is just a packet header) separa

Re: Parsing data from pyserial

2006-12-03 Thread Grant Edwards
On 2006-12-03, Lone Wolf <[EMAIL PROTECTED]> wrote: > import serial > > ser=serial.Serial('com1',baudrate=115200, bytesize=8, > parity='N', stopbits=1,xonxoff=0, timeout=1) > > ser.write("PM 1") #This sets the CMUcam to poll mode > > for i in range(0,100,1): > ser.write("TC 016 240 100 240 0

Re: Parsing data from pyserial

2006-12-03 Thread Giovanni Bajo
Lone Wolf wrote: > reading = ser.read(40) Simply try ser.readline() here, or maybe ser.readline(eol="\r"). -- Giovanni Bajo -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing data from pyserial

2006-12-02 Thread Hendrik van Rooyen
"Lone Wolf" <[EMAIL PROTECTED]> wrote: > I'm trying to get data through my serial port from a CMUcam. > This gizmo tracks a color and returns a packet of data. The > packet has nine data points (well, really eight since the first > point is just a packet header) separated by spaces as follows: M >

Re: Parsing data from pyserial

2006-12-02 Thread John Machin
Lone Wolf wrote: > I'm trying to get data through my serial port from a CMUcam. > This gizmo tracks a color and returns a packet of data. The > packet has nine data points (well, really eight since the first > point is just a packet header) separated by spaces as follows: M > xxx xxx xxx xxx xxx xx

Re: Parsing Data, Storing into an array, Infinite Backslashes

2005-07-13 Thread [EMAIL PROTECTED]
I ended up using this code to solve my problem. > for a, b, c, d in s: > if not query.has_key((a,b)): query[(a,b)] = [] >query[(a,b)].append("%s=%s" % (c, d)) > for (a,b), v in query.items(): >print a, b, ", ".join(v) I'm relatively new to python/programming in general. I usually writ

Re: Parsing Data, Storing into an array, Infinite Backslashes

2005-07-12 Thread [EMAIL PROTECTED]
Thanks for all the help, I'm not sure what approach I'm going to try but I think I'll try all of your suggestions and see which one fits best. The variable "i" held the following array: [['Memory', '0', 'Summary', '0'], ['Memory', '0', 'Speed', 'PC3200U-30330'], ['Memory', '0', 'Type', 'DDR SDRAM

Re: Parsing Data, Storing into an array, Infinite Backslashes

2005-07-11 Thread Steven D'Aprano
On Mon, 11 Jul 2005 13:47:22 -0700, [EMAIL PROTECTED] wrote: > I am using this function to parse data I have stored in an array. > > This is what the array looks like: > > [['Memory', '0', 'Summary', '0'], ['Memory', '0', 'Speed', > 'PC3200U-30330'], ['Memory', '0', 'Type', 'DDR SDRAM'], ... ]

Re: Parsing Data, Storing into an array, Infinite Backslashes

2005-07-11 Thread Jeff Epler
Your code is needlessly complicated. Instead of this business while 1: try: i = fetch.next() except stopIteration: break simply write: for i in fetch: (if there's an explicit 'fetch = iter(somethingelse)' in code you did not show, then get rid of tha

Re: Parsing data from URL

2005-04-25 Thread Kartic
"The Great 'Harlin Seritt' uttered these words" on 4/24/2005 8:24 PM: How can I make sure that I get the actual html data instead of the data from redirected URL? thanks, Harlin Harlin, I am not sure I understand what you are asking but please see if the below mentioned link will help you. I am ju

Re: Parsing data from URL

2005-04-24 Thread R. C. James Harlow
On Monday 25 April 2005 01:24, Harlin Seritt wrote: > dat = urllib.urlopen(url, 'r').read() Drop the 'r' - urlopen is posting the 'r' to the server, instead of doing what you mean, opening the file read-only. pgpmZ2zcMs1bO.pgp Description: PGP signature -- http://mail.python.org/mailman/listi

Re: Parsing data from URL

2005-04-24 Thread could ildg
I think it depends on the server On 24 Apr 2005 17:24:18 -0700, Harlin Seritt <[EMAIL PROTECTED]> wrote: > I am trying to do the following: > > > > import urllib > > url = 'http://www.website.com/file.shtml' > dat = urllib.urlopen(url, 'r').read() > print dat > > When I do so, I get the follo