CSV Files

J

jp2msft

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.
 
M

Marc Gravell

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
 
K

Ken Halter

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.
 
J

jp2msft

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?
 
I

Ignacio Machin ( .NET/ C# MVP )

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
 
I

Ignacio Machin ( .NET/ C# MVP )

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top