473,387 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

create a text file

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
May 29 '06 #1
6 10585
Stan Cook wrote:
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>

May 29 '06 #2
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).
May 29 '06 #3
Hi,

This is what I often do:

somekindofoutput = ''
somekindofoutput += somefunk(somearg) + '\n'

# w is for writing
myfile = open('theoutfile',w)
myfile.write(somekindofoutput)
myfile.close()

also see
http://www.python.org/doc/2.3.5/tut/node9.html
or some other documentation

/P9k

May 30 '06 #4
"per9000" <pe*****@gmail.com> wrote:
# 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

May 30 '06 #5
Max Erickson wrote:
# w is for writing
myfile = open('theoutfile',w)


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


w = 'w'

</F>

May 30 '06 #6
Fredrik Lundh wrote:
Stan Cook wrote:
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>

Thanks, I found it.
Jun 4 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
1
by: Andrew Chanter | last post by:
I am writing a little routine to perform the following operations from an Acces 97 mdb: 1. create a fixed width text file 2. create/establish a table type link to the text file in Access 3....
13
by: Dan V. | last post by:
How do I create a one line text file with these control codes? e.g.: 144 = 0x90 and 147 = 0x93? I am trying to create a one line text file with these characters all one one row with no spaces. ...
6
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the...
1
by: JenHu | last post by:
Hi experts, I want to create a new empty text file after I upload a file to the desination. Then I need to read each line from the uploaded file and write the lines which first character <>'6'...
6
by: windandwaves | last post by:
Hi Folk Some of my clients asked me to create "fancy emails" for them (aka html formatted emails). I know how to make a nice html document, but I had trouble creating a simple way to provide...
0
by: CSharpguy | last post by:
I have a web form that has 22 text boxes on it were the user can enter in data, then click a button that needs to create a text file. I can create the text file fine, but how can I create a text...
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.