> > I'm in a process of rewriting a bash/awk/sed script -- that grew to
> > big -- in python. I can rewrite it in a simple line-by-line way but
> > that results in ugly python code and I'm sure there is a simple
> > pythonic way.
> >
> > The bash script processed text files of the form:
> >
> > ###
On Mar 23, 5:30 pm, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote:
> Hi list,
>
> I'm in a process of rewriting a bash/awk/sed script -- that grew to
> big -- in python. I can rewrite it in a simple line-by-line way but
> that results in ugly python code and I'm sure there is a simple
> pythonic way.
On Mar 23, 10:30 pm, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote:
> Hi list,
>
> I'm in a process of rewriting a bash/awk/sed script -- that grew to
> big -- in python. I can rewrite it in a simple line-by-line way but
> that results in ugly python code and I'm sure there is a simple
> pythonic way.
> This is my first try:
>
> ddata = {}
>
> inside_matrix = False
> for row in file("data.txt"):
> if row.strip():
> fields = row.split()
> if len(fields) == 2:
> inside_matrix = False
> ddata[fields[0]] = [fields[1]]
> lastkey = fields[0]
>
Daniel Nogradi:
> Any elegant solution for this?
This is my first try:
ddata = {}
inside_matrix = False
for row in file("data.txt"):
if row.strip():
fields = row.split()
if len(fields) == 2:
inside_matrix = False
ddata[fields[0]] = [fields[1]]
Hi list,
I'm in a process of rewriting a bash/awk/sed script -- that grew to
big -- in python. I can rewrite it in a simple line-by-line way but
that results in ugly python code and I'm sure there is a simple
pythonic way.
The bash script processed text files of the form:
###
Harold> To illustrate, assume I have a text file, call it test.txt, with
Harold> the following information:
Harold> X11 .32
Harold> X22 .45
Harold> My goal in the python program is to manipulate this file such
Harold> that a new file would be created that looks like:
I am beginning to use python primarily to organize data into formats
needed for input into some statistical packages. I do not have much
programming experience outside of LaTeX and R, so some of this is a bit
new. I am attempting to write a program that reads in a text file that
contains some value