473,794 Members | 2,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiline CSV export to Excel produces unrecognized characters?

Hi --

Is there a standard way to use the csv module to export data that
contains multi-line values to Excel? I can get it mostly working, but
Excel seems to have difficulty displaying the generated multi-line
cells.

The following reproduces the problem in python 2.5:

import csv
row = [1,"hello","th is is\na multiline\ntext field"]
writer = csv.writer(open ("test.tsv", "w"), dialect="excel-tab",
quotechar='"')
writer.writerow (row)

When opening the resulting test.tsv file, I do indeed see a cell with
a multi-line value, but there is a small boxed question mark at the
end of each of the lines, as if Excel didn't recognize the linebreak.

Any idea why these are there or how to get rid of them?

Ramon
Mar 24 '08 #1
2 5902
On Sun, 23 Mar 2008 23:30:11 -0700, felciano wrote:
The following reproduces the problem in python 2.5:

import csv
row = [1,"hello","th is is\na multiline\ntext field"]
writer = csv.writer(open ("test.tsv", "w"), dialect="excel-tab",
quotechar='"')
writer.writerow (row)

When opening the resulting test.tsv file, I do indeed see a cell with
a multi-line value, but there is a small boxed question mark at the
end of each of the lines, as if Excel didn't recognize the linebreak.

Any idea why these are there or how to get rid of them?
Any chance you are doing this on Windows and Excel doesn't like the
return+linefeed line endings that Windows produces when writing files in
text mode? Try 'wb' as mode for the output file.

Ciao,
Marc 'BlackJack' Rintsch
Mar 24 '08 #2
>
Any chance you are doing this on Windows and Excel doesn't like the
return+linefeed line endings that Windows produces when writing files in
text mode? Try 'wb' as mode for the output file.

Ciao,
Marc 'BlackJack' Rintsch
Fixed! Can't believe I missed that...

Thank you for the quick reply!

Ramon
Mar 24 '08 #3

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

Similar topics

0
1906
by: Bryan Russell | last post by:
Hi, My asp/sql server application gets an error, but only when you use the Excel export option: <% Response.ContentType="application/vnd.ms-excel" %> (very popular w/ users) I think somebody entered a string of characters that Excel does not like
0
4184
by: Simon | last post by:
Dear reader, By export a query to Excel the memo-field is cutoff to 255 characters in Excel. I do not know how I can export the total content of the memo field, more
4
3437
by: Anthony Cuttitta Jr. | last post by:
I'm working on some procedures where Access queries are exported to Excel, and then later on, those same workbooks are openned, and I need to target a specific original sheet. Sometimes there will be multiple sheets in the same workbook, sometimes only a single tab. The issue is this: Save query "XLTest - qryExport" to file and the worksheet name becomes "XLTest___qryExport" (three underscores). I have a generic procedure which...
1
2101
by: JMCN | last post by:
hello does anyone know why is there a character limitation (255) in excel when i export from the reports object in excel access? if i created a macro using the transferspreadsheet action from the query with the field of + 255 characters, it will export all characters. why is there a character limitation in the reports when exporting to excel? thanks in advance - jung
3
8029
by: nologin | last post by:
Is it possible to export data exposed by DataView to Excel file for example ? Seba
8
13255
by: Taffman | last post by:
I've searched this goup for an answer to this, there are many discussions that come close but non that I can find that actually addresses this particular problem. I'm exporting queries to Excel. These queries have memo fields in them Each memo field is trunkated, i.e cuts off after 255 characters. Is there any way either via VBA or otherwise to get all my memo text to export to Excel. I note that there is no such limit when exporting...
1
3646
by: musicloverlch | last post by:
I need to export a query to Excel with a memo field. The memo field keeps getting cut off at 255 characters. If I just cut and paste, I get the whole memo field. I need it in Excel without having to go through all that. Any ideas? Thanks! Laura
2
12916
by: Nefaria | last post by:
I'm constantly required to export data from Access to Excel for formatting and find it extremely difficult to remove the Chr(10) and Chr(13) codes from the imported data. A search and replace in Excel doesn't recognize the characters and I can find no 'quick' way of fixing this problem, is there a way of making sure the characters don't come across during an export (they appear as boxes in Excel) or is there code that I can use in Excel to...
7
28905
Merlin1857
by: Merlin1857 | last post by:
Its great producing data for users to look at in your web pages and generally that is sufficient for their needs but sometimes you may want to supply your user with the data in a form they can actually do something more with. This code shows you how to display data from your database and then how to give that data to the user in the form of a useable Excel spreadsheet which they can then take away and play with themselves. The way I have shown...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10435
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.