On Aug 7, 2008, at 12:52 PM, Mike Driscoll wrote:
I'm well aware of the split() method and built-ins, however since this
appeared to be a homework-type question and I was at work, I didn't
spend any time on the issue. The only reason I mentioned McGuire's
PyParsing module was because I had just
On Aug 6, 4:06 pm, John Machin <[EMAIL PROTECTED]> wrote:
> On Aug 7, 6:02 am, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 6, 1:55 pm, Tommy Grav <[EMAIL PROTECTED]> wrote:
>
> > > I have a file with the format
>
> > > Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Fr
Tommy Grav a écrit :
I have a file with the format
Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames 5
Set 1
Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames 5
Set 2
Field f31226: Ra=20:24:45.50 Dec=+78:26:45.2 MJD=53370.06823860 Frames 5
Set 3
Field
Paul McGuire:
> This code creates a single dict for the input lines, keyed by id.
> Each value contains elements labeled 'id', 'ra', and 'mjd'.
...
> d = dict(
> (rec.split()[1][:-1],
> dict([('id',rec.split()[1][:-1])] +
> [map(str.lower,f.split('='))
>
On Aug 6, 3:14 pm, "Shawn Milochik" <[EMAIL PROTECTED]> wrote:
> Regular expressions will do the trick nicely.
>
Or just use str.split, and create dicts using dict(list_of_tuples)
constructor.
This code creates a single dict for the input lines, keyed by id.
Each value contains elements labeled '
On Aug 6, 3:55 pm, Tommy Grav <[EMAIL PROTECTED]> wrote:
> I have a file with the format
>
> Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames
> 5 Set 1
> Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames
> 5 Set 2
> Field f31226: Ra=20:24:45.50 Dec=+78
On Aug 7, 7:06 am, John Machin <[EMAIL PROTECTED]> wrote:
> On Aug 7, 6:02 am, Mike Driscoll <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Aug 6, 1:55 pm, Tommy Grav <[EMAIL PROTECTED]> wrote:
>
> > > I have a file with the format
>
> > > Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Fr
Using something like PyParsing is probably better, but if you don't
want to use it you may use something like this:
raw_data = """
Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames
5 Set 1
Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames
5 Set 2
Field f31
On Aug 7, 6:02 am, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Aug 6, 1:55 pm, Tommy Grav <[EMAIL PROTECTED]> wrote:
>
>
>
> > I have a file with the format
>
> > Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames
> > 5 Set 1
> > Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJ
Shawn Milochik wrote:
>> I would like to parse this file by extracting the field id, ra, dec and mjd
>> for each line. It is
>> not, however, certain that the width of each value of the field id, ra, dec
>> or mjd is the same
>> in each line. Is there a way to do this such that even if there was a
>
> I would like to parse this file by extracting the field id, ra, dec and mjd
> for each line. It is
> not, however, certain that the width of each value of the field id, ra, dec
> or mjd is the same
> in each line. Is there a way to do this such that even if there was a line
Regular expressions
On Aug 6, 1:55 pm, Tommy Grav <[EMAIL PROTECTED]> wrote:
> I have a file with the format
>
> Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames
> 5 Set 1
> Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames
> 5 Set 2
> Field f31226: Ra=20:24:45.50 Dec=+78
I have a file with the format
Field f29227: Ra=20:23:46.54 Dec=+67:30:00.0 MJD=53370.06797690 Frames
5 Set 1
Field f31448: Ra=20:24:58.13 Dec=+79:39:43.9 MJD=53370.06811620 Frames
5 Set 2
Field f31226: Ra=20:24:45.50 Dec=+78:26:45.2 MJD=53370.06823860 Frames
5 Set 3
Field f31004: Ra=20:25:0
13 matches
Mail list logo