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

writeto csv file

Hello,

I have the following code to write each columns in a
datarow to the csv file:
myStreamWriter.Write(chr(34) & (myDr(I).ToString) & chr(34)
& ",")
I have a string field with the value of "000000". When I
open the file in Excel, the value displayed as "0". But I
really need to keep the way it is in the database. I tried
the following:
myStreamWriter.Write(chr(39) & (myDr(I).ToString) & ",")
It displayed as "'000000".
What should I do to display the value correctly in the CSV
file?

Thanks for any help!

Mei

Nov 18 '05 #1
3 921
Are you sure the actual csv file is being outputted incorrectly? You said you opened it in excel, which will take your 000000 and make it into a 0 (that's just excel's problem), but if the csv file itself is ok, you are good to go. By the way, from a programming standpoint, always open csv files from a text editor, not excel, excel will change it around as you've found out!
"Mei Qin" <an*******@discussions.microsoft.com> wrote in message news:1c*****************************@phx.gbl...
Hello,

I have the following code to write each columns in a
datarow to the csv file:
myStreamWriter.Write(chr(34) & (myDr(I).ToString) & chr(34)
& ",")
I have a string field with the value of "000000". When I
open the file in Excel, the value displayed as "0". But I
really need to keep the way it is in the database. I tried
the following:
myStreamWriter.Write(chr(39) & (myDr(I).ToString) & ",")
It displayed as "'000000".
What should I do to display the value correctly in the CSV
file?

Thanks for any help!

Mei

Nov 18 '05 #2
The customer need to open the CSV file in Excel, so they
can sort, filter on the data.
-----Original Message-----
Are you sure the actual csv file is being outputted incorrectly? You said you opened it in excel, which will
take your 000000 and make it into a 0 (that's just excel's
problem), but if the csv file itself is ok, you are good
to go. By the way, from a programming standpoint, always
open csv files from a text editor, not excel, excel will
change it around as you've found out!

"Mei Qin" <an*******@discussions.microsoft.com> wrote in

message news:1c*****************************@phx.gbl...
Hello,

I have the following code to write each columns in a
datarow to the csv file:
myStreamWriter.Write(chr(34) & (myDr(I).ToString) & chr (34) & ",")
I have a string field with the value of "000000". When I open the file in Excel, the value displayed as "0". But I really need to keep the way it is in the database. I tried the following:
myStreamWriter.Write(chr(39) & (myDr(I).ToString) & ",")
It displayed as "'000000".
What should I do to display the value correctly in the CSV file?

Thanks for any help!

Mei

.

Nov 18 '05 #3
Then in that case, you are probably going to need to surround all text values like this in quotes

"000000", "ABC", 45, 2837

"Mei Qin" <an*******@discussions.microsoft.com> wrote in message news:1c*****************************@phx.gbl...
The customer need to open the CSV file in Excel, so they
can sort, filter on the data.
-----Original Message-----
Are you sure the actual csv file is being outputted

incorrectly? You said you opened it in excel, which will
take your 000000 and make it into a 0 (that's just excel's
problem), but if the csv file itself is ok, you are good
to go. By the way, from a programming standpoint, always
open csv files from a text editor, not excel, excel will
change it around as you've found out!


"Mei Qin" <an*******@discussions.microsoft.com> wrote in

message news:1c*****************************@phx.gbl...
Hello,

I have the following code to write each columns in a
datarow to the csv file:
myStreamWriter.Write(chr(34) & (myDr(I).ToString) & chr (34) & ",")
I have a string field with the value of "000000". When I open the file in Excel, the value displayed as "0". But I really need to keep the way it is in the database. I tried the following:
myStreamWriter.Write(chr(39) & (myDr(I).ToString) & ",")
It displayed as "'000000".
What should I do to display the value correctly in the CSV file?

Thanks for any help!

Mei

.

Nov 18 '05 #4

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

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
7
by: Joseph | last post by:
Hi, I'm having bit of questions on recursive pointer. I have following code that supports upto 8K files but when i do a file like 12K i get a segment fault. I Know it is in this line of code. ...
3
by: Zoury | last post by:
Hi folks ! :O) I'm trying to show a PDF in ASP.NET but I can't get to work properly. here's a portion of my code : '** Dim ms As MemoryStream =...
2
by: Charles.Deisler | last post by:
I'm reading a xmldocument in from the file system and using xmldocument.writeto(xmltextwriter) to stream the xml data to the response.outputstream. From what i've read, reading an xmldocument is...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
5
by: Andy Fish | last post by:
Hi, I am using XmlDocument.WriteTo() and I find that the xml declaration is not included. at the moment I am doing this: XmlTextWriter xw = new XmlTextWriter(...); xw.WriteStartDocument();...
2
by: William | last post by:
I am attempting to write an XmlDocument to file, but for some reason it will only write 2048 characters of the document even though when I stop it in the debugger ALL of the document is there. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.