473,396 Members | 1,805 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,396 software developers and data experts.

slight csv misbehavior under Windows

I'm using the csv module in python 2.3 under Windows XP; it seems that
two separate mechanisms try to handle the perverse Windows habit of
ending lines with 0d0a, and so

writer = csv.writer(file('foo.csv','w'))
for i in thing:
writer.write(i)

produces lines ending 0d0d0a, and when you load this into Excel 97 the
data appears double-spaced.

Opening the file with 'wb' solves the problem, but it would be lovely
were this either fixed or documented; it's rather unintuitive that a
file opened with 'wb' still ends lines with 0d0a.

Please tell me if this is not the appropriate place to make this kind
of bug report.

Tom
Jul 18 '05 #1
1 1879
I think that "wb" is obviously the correct format, and this is not
a bug. CSV fields that contain an end of line within the field contain
a single character end-of-line marker (I can never remember whether
this is \r or \n), and this is not kosher for a Windows text file,
so it must be a binary file.
Al

Thomas Womack wrote:

I'm using the csv module in python 2.3 under Windows XP; it seems that
two separate mechanisms try to handle the perverse Windows habit of
ending lines with 0d0a, and so

writer = csv.writer(file('foo.csv','w'))
for i in thing:
writer.write(i)

produces lines ending 0d0d0a, and when you load this into Excel 97 the
data appears double-spaced.

Opening the file with 'wb' solves the problem, but it would be lovely
were this either fixed or documented; it's rather unintuitive that a
file opened with 'wb' still ends lines with 0d0a.

Please tell me if this is not the appropriate place to make this kind
of bug report.

Tom

Jul 18 '05 #2

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

Similar topics

2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
4
by: Adam Maltby | last post by:
Hi, I need to do a transparent label but with a difference. I have drawn on my form a custom background using CreateGraphics as I needed an ellipse looking fill in a rectangle - so the actual...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
2
by: sambo251 | last post by:
After running a few updates I get this very annoying "Windows Installer" error #1706 that will ne go away! It keeps saying that it cannot find the file "instantsharedevices.msi", that it is on...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
2
by: nicola | last post by:
hello, I need a simple and slight forum write in c# exume me, for the ot, but I'm desperated
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.