Thanks for the responses. I appreciate your help and pointers to
statements and modules I was not aware of.
I appreciate leaning about the "evil tab" and attempt to vanish it
from any future emails form me.
Charles
___
Tutor maillist - Tutor@python.o
>
> The indentation came through fine for me. The Basic code is indented
> with spaces, the Python code with tabs. Perhaps your mail reader doesn't
> correctly interpret the tabs.
>
This presents a perfect opportunity to remind our new Pythonistas that tabs
can be evil (for precisely this reason),
Tiger12506 wrote:
> Indentation is paramount in python. Your QBasic code is indented in the
> email, so I can safely assume that the email is not what's messing up the
> indentation.
The indentation came through fine for me. The Basic code is indented
with spaces, the Python code with tabs. Pe
bob gailer wrote:
> f2 = open(outfile, 'w')
> for line in f1:
> if s.startswith(".block"): # start of block
> s2 = []
> elif s==".endblock":
> f2.write(",".join(s2) + "\n")
> else: # data record
> s2.append('"%s"' % line.strip())
This is
Tiger12506 wrote:
> And s2 = s2[:-1] + s
> can be written as
> s2 = s2+s
No, these are not equivalent, the original version strips the last
character from s2.
Kent
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
C B Gambrell wrote:
> I am just getting started with Python and wonder if folks here might
> look at this attempt in Python and offer me your thoughts.
>
> Several years ago I used QBasic to convert one our reports to a csv
> file so we could import the data into another program. That very old
> Q
> infile$ = "ad.txt"
> outfile$ = "ad.csv"
> infile=sys.argv[1]
> outfile=sys.argv[1]+".csv"
And these will give two different results. The QBasic version says
"ad.txt"
"ad.csv"
whereas the python version will give
"ad.txt"
"ad.txt.csv"
so you need to say
infile = sys.argv[1]
outfile = sys.arg
> And here is my I got work for me in Python.
>
> ===
> ===
> import sys
> infile=sys.argv[1]
> outfile=sys.argv[1]+".csv"
>
> f1=open(infile)
> f2=open(outfile, 'w')
>
> s2=""
>
> for line in f1:
> s=line.strip()
> if s=="":
> continue
> elif s==".block":
> continue
> elif s==".report":
> continue
I am just getting started with Python and wonder if folks here might
look at this attempt in Python and offer me your thoughts.
Several years ago I used QBasic to convert one our reports to a csv
file so we could import the data into another program. That very old
QBasic script has been serving m