create a text file

S

Stan Cook

I'm writing a script to list all of my music files' id3 tags
to a comma delimited file. The only part I'm missing seems
like it should be the simplest. I haven't used Python for
the last couple of years. My question is this:

When I use os.open(<file_variable>,"w"), I get an error
message, TypeError: an integer is required. Has
something changed? Did I miss something???

Thanks,

-------------------> S Cook
 
F

Fredrik Lundh

Stan said:
I'm writing a script to list all of my music files' id3 tags
to a comma delimited file. The only part I'm missing seems
like it should be the simplest. I haven't used Python for
the last couple of years. My question is this:

When I use os.open(<file_variable>,"w"), I get an error
message, TypeError: an integer is required. Has
something changed? Did I miss something???

the function is called "open", not "os.open".

there's an open function in the os module, but that's doing something
slightly different (see the library reference documentation for details
if you're curious).

</F>
 
B

Bruno Desthuilliers

Stan Cook a écrit :
I'm writing a script to list all of my music files' id3 tags to a comma
delimited file. The only part I'm missing seems like it should be the
simplest. I haven't used Python for the last couple of years. My
question is this:

When I use os.open(<file_variable>,"w"), I get an error message,
TypeError: an integer is required. Has something changed? Did I miss
something???

You want open() (the builtins one), not os.open().

Also, if you want to deal with csv files, you may want to check the csv
module (if you don't use it already).
 
M

Max Erickson

per9000 said:
# w is for writing
myfile = open('theoutfile',w)

That won't work, the second argument to open needs to be a string:

myfile = open('theoutfile', 'w')


max
 
S

Stan Cook

Fredrik said:
the function is called "open", not "os.open".

there's an open function in the os module, but that's doing something
slightly different (see the library reference documentation for details
if you're curious).

</F>
Thanks, I found it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,297
Messages
2,571,536
Members
48,283
Latest member
SherriP988

Latest Threads

Top