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

CSV Files

I've got a project that I'm sending output to a CSV file.

Some of the fields have commas in them and some of the fields have spaces.

When I attempt to open the file with a double click or Process.Start, the
default application opens it: MS Excel. This is fine.

However, every time Excel opens one of these files, it defaults to a "Fixed
Width" data type.

I have tried encapsulating each of my cells in quotes, and I have replaced
all of the commas with dots, but neither has solved this problem.

I understand how to go into the Text Import Wizard of Excel to set the data
type as a delimited file using commas, but this app is going out to
supervisors and managers in our plant that aren't so good with computers.

Is there some setting that I can use to ensure that my files default as a
delimited file without physically creating a proprietary MS Excel file?

I can not replace the spaces in the cells, because those are required to
have a proper model numbers in our company.

I appreciate any help.
Jul 17 '08 #1
8 1750
On Thu, 17 Jul 2008 14:50:01 -0700, jp2msft
<jp*****@discussions.microsoft.comwrote:
[...]
Is there some setting that I can use to ensure that my files default as a
delimited file without physically creating a proprietary MS Excel file?
I have to say, I don't see anything in your question that technically is
related to C#, .NET, or programming at all for that matter. You seem to
be asking about how _Excel_ treats specific text file formats, and that's
a question that you'd get a _much_ better answer for in a newsgroup
specifically about Excel.

Now, that said...based on what I know about Excel, I believe that there's
nothing you can do about the default way it will open a CSV file. You'll
have to go through the Text Import Wizard, or at the very least code up a
macro that your clients can use to open the file (I think it's possible
you could write an add-in that would watch for text files being opened,
and then run the Text Import on the newly opened file to do what you want,
but don't hold me to that :)...in any case, if you did that, your clients
would have to install the add-in for any Excel installation they wanted to
work that way).

Does the file have to be CSV? If you wrote the data out as an XML file,
it's a bit easier for Excel to figure out what you want. It has a default
XML import mode that I've found works very nicely for database-like data.

Pete
Jul 17 '08 #2
Off topic, btw.
Commas nor spaces shouldn't be a problem if you have quoted the field;
do you have a short (say, 2 line, 6 cell) example of something that
loads incorrectly? It could be a setting on your machine?
Alternatively note that some (not all) European versions of Excel
default to using period for the delimiter (gotta love i18n....).

Marc
Jul 17 '08 #3
fwiw, CSV is a standardized format... RFCs and all...

http://www.fileformat.info/format/csv/internal.htm

Before I found that site, though... I opened Excel, manually entered a few
rows/cols of data, using just about every combination of comma's and quotes
I could think of and exported that from Excel to a CSV file.... finally,
inspecting the file and duplicating its format in code, using the same data
I originally entered into Excel... didn't stop until they matched <g>

But... iirc, ADO has built in CSV file I/O, so ADO.Net should (VB6 dev here,
just poking around the groups temporarily). I wrote my own from scratch as a
"drop-in" class, so I didn't need to package the ADO components, or anything
else... same with the limited XML stuff I do.... a single "drop-in" class
replaces all XML components I'd need to package.
"jp2msft" <jp*****@discussions.microsoft.comwrote in message
news:BE**********************************@microsof t.com...
I've got a project that I'm sending output to a CSV file.

Some of the fields have commas in them and some of the fields have spaces.

When I attempt to open the file with a double click or Process.Start, the
default application opens it: MS Excel. This is fine.

However, every time Excel opens one of these files, it defaults to a
"Fixed
Width" data type.

I have tried encapsulating each of my cells in quotes, and I have replaced
all of the commas with dots, but neither has solved this problem.

I understand how to go into the Text Import Wizard of Excel to set the
data
type as a delimited file using commas, but this app is going out to
supervisors and managers in our plant that aren't so good with computers.

Is there some setting that I can use to ensure that my files default as a
delimited file without physically creating a proprietary MS Excel file?

I can not replace the spaces in the cells, because those are required to
have a proper model numbers in our company.

I appreciate any help.

Jul 17 '08 #4
Do you have a "go to" link for the XML creation?

I've seen how to create XML files online and in books, but what I'd like to
see is how to setup the nodes and such. (I've never actually had an
opportunity to generate an XML file)

Would the XML file still be saved as a CSV file or would I give it an XML
extension?

"Peter Duniho" wrote:
Does the file have to be CSV? If you wrote the data out as an XML file,
it's a bit easier for Excel to figure out what you want. It has a default
XML import mode that I've found works very nicely for database-like data.

Pete
Jul 18 '08 #5
Yeah, Pete indicated to me it was off topic too. Sorry, but I didn't feel the
Excel guys would want to talk to a software developer.

Here are a couple of files:
http://www.joeswelding.biz/test/DataGrid_Viewer.csv (larger)
http://www.joeswelding.biz/test/Pack...o_07172008.csv (one line only)

"Marc Gravell" wrote:
Off topic, btw.
Commas nor spaces shouldn't be a problem if you have quoted the field;
do you have a short (say, 2 line, 6 cell) example of something that
loads incorrectly? It could be a setting on your machine?
Alternatively note that some (not all) European versions of Excel
default to using period for the delimiter (gotta love i18n....).

Marc
Jul 18 '08 #6
On Jul 17, 5:50*pm, jp2msft <jp2m...@discussions.microsoft.comwrote:
I've got a project that I'm sending output to a CSV file.

Some of the fields have commas in them and some of the fields have spaces..
Go to opennetcf.org and download theirs provider. You can create (and
consume) .csv files like a charm. No point in creating a new parser
Jul 18 '08 #7
Now, that said...based on what I know about Excel, I believe that there's*
nothing you can do about the default way it will open a CSV file. *
My bet is that the OP got wrong the csv creation
Jul 18 '08 #8
On Fri, 18 Jul 2008 06:38:04 -0700, jp2msft
<jp*****@discussions.microsoft.comwrote:
Do you have a "go to" link for the XML creation?

I've seen how to create XML files online and in books, but what I'd like
to
see is how to setup the nodes and such. (I've never actually had an
opportunity to generate an XML file)
I think that the documentation for the XmlWriter class would be a good
place to start:
http://msdn.microsoft.com/en-us/libr...xmlwriter.aspx
Would the XML file still be saved as a CSV file or would I give it an XML
extension?
It can have whatever extension you want (my recollection is that Excel
detects the XML from the header), but ".xml" is probably the best choice.
The ".csv" extension would definitely be inappropriate, even if it still
worked.

That said, others have suggested that Excel will in fact default to
comma-delimited fields if you format your CSV file correctly. If you can
get Excel to generate a CSV file that it then reads in correctly, then I
would think that would be an indication that those suggestions are
correct. In that case, you should just look at the difference between
what Excel is writing and what you're writing and fix the differences so
that you're following what Excel expects.

Pete
Jul 18 '08 #9

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

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
3
by: pooja | last post by:
Suppose i have created a class c1 with f1()in c1.cpp and included this c1.cpp in file1.cpp file , which is also having main() by giving the statement #include "c1.cpp". the same i can do by...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
0
by: wal | last post by:
How does one attach files to emails using libgmail? The following code http://pramode.net/articles/lfy/fuse/4.txt works fine when said files are simple text files, but it failes as soon as the...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
2
by: Chocolade | last post by:
I have a console application project wich inside im creating array of jpg files from a directory and then im formating the files and make new files and i want to reneame/move/copy the new files with...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.