I am writing a console app in c# wherein am converting a dataset into a CSV
file. It works fine. But I have some values in the dataset which have a comma
within(eg. A,B,C). When I view the CSV file in Excel, the multiple values
which are separated by the 'comma' in the dataset are being displayed in the
next column , which I dont want that way. I want to retain any commas which
are present in my dataset.
How do I handle such a scenario?
Thanks
Deepa 8 5687
You could do a couple things. If you put quotes around your text (called
text qualifier), "A,B,C" then Excel will ignore the commas within the
quotes. Another choice is to use a deliminator other than a comma, such as
a TAB or a pipe.
Kevin
"Deepa" <De***@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com... I am writing a console app in c# wherein am converting a dataset into a CSV file. It works fine. But I have some values in the dataset which have a comma within(eg. A,B,C). When I view the CSV file in Excel, the multiple values which are separated by the 'comma' in the dataset are being displayed in the next column , which I dont want that way. I want to retain any commas which are present in my dataset. How do I handle such a scenario?
Thanks Deepa
Kevin
I tried using the tab and the pipe delimiters but the resulting output file
when viewed in excel isnt the same as i want it.(similar to a csv).
I thought of the double quotes but am not able to figure out how I write the
code to see what values in the dataset have a comma or not.
Would appreciate a response to this.
Thanks
Deepa
"Kevin Thomas" wrote: You could do a couple things. If you put quotes around your text (called text qualifier), "A,B,C" then Excel will ignore the commas within the quotes. Another choice is to use a deliminator other than a comma, such as a TAB or a pipe.
Kevin
"Deepa" <De***@discussions.microsoft.com> wrote in message news:16**********************************@microsof t.com...I am writing a console app in c# wherein am converting a dataset into a CSV file. It works fine. But I have some values in the dataset which have a comma within(eg. A,B,C). When I view the CSV file in Excel, the multiple values which are separated by the 'comma' in the dataset are being displayed in the next column , which I dont want that way. I want to retain any commas which are present in my dataset. How do I handle such a scenario?
Thanks Deepa
You don't have to worry about which values have a comma or not. If the
field is a text field (or you want it treated as such by Excel) just enclose
it in quotes. You might have a row that ends up looking like:
"abcdef", "23klk,23,23", "eeeejjj","eee,t,r", 9,5
So you see, you put quotes around all your text fields. If one ends up with
a comma in it, Excel will ignore it because it's in quotes.
Kev
"Deepa" <De***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com... Kevin I tried using the tab and the pipe delimiters but the resulting output file when viewed in excel isnt the same as i want it.(similar to a csv). I thought of the double quotes but am not able to figure out how I write the code to see what values in the dataset have a comma or not. Would appreciate a response to this.
Thanks Deepa
"Kevin Thomas" wrote:
You could do a couple things. If you put quotes around your text (called text qualifier), "A,B,C" then Excel will ignore the commas within the quotes. Another choice is to use a deliminator other than a comma, such as a TAB or a pipe.
Kevin
"Deepa" <De***@discussions.microsoft.com> wrote in message news:16**********************************@microsof t.com... >I am writing a console app in c# wherein am converting a dataset into a >CSV > file. It works fine. But I have some values in the dataset which have a > comma > within(eg. A,B,C). When I view the CSV file in Excel, the multiple > values > which are separated by the 'comma' in the dataset are being displayed > in > the > next column , which I dont want that way. I want to retain any commas > which > are present in my dataset. > How do I handle such a scenario? > > Thanks > Deepa
Thanks dude. Just curious if you can help me with something else.
I have this dataset am converting into a csv file. Before I write to the
output.csv I want to sort the values of the dataset in ascending order. I
just have one single table in my dataset. I have the dataset ready, i mean to
say am not making any connection to the database to populate the dataset. I
have it as an xml dataset file. And am just saying ds.ReadXml(the xml file
path)
Before I loop thru the dataset, I want to sort it.
Any ideas?
thanks
Deepa
"Kevin Thomas" wrote: You don't have to worry about which values have a comma or not. If the field is a text field (or you want it treated as such by Excel) just enclose it in quotes. You might have a row that ends up looking like:
"abcdef", "23klk,23,23", "eeeejjj","eee,t,r", 9,5
So you see, you put quotes around all your text fields. If one ends up with a comma in it, Excel will ignore it because it's in quotes.
Kev
"Deepa" <De***@discussions.microsoft.com> wrote in message news:9F**********************************@microsof t.com... Kevin I tried using the tab and the pipe delimiters but the resulting output file when viewed in excel isnt the same as i want it.(similar to a csv). I thought of the double quotes but am not able to figure out how I write the code to see what values in the dataset have a comma or not. Would appreciate a response to this.
Thanks Deepa
"Kevin Thomas" wrote:
You could do a couple things. If you put quotes around your text (called text qualifier), "A,B,C" then Excel will ignore the commas within the quotes. Another choice is to use a deliminator other than a comma, such as a TAB or a pipe.
Kevin
"Deepa" <De***@discussions.microsoft.com> wrote in message news:16**********************************@microsof t.com... >I am writing a console app in c# wherein am converting a dataset into a >CSV > file. It works fine. But I have some values in the dataset which have a > comma > within(eg. A,B,C). When I view the CSV file in Excel, the multiple > values > which are separated by the 'comma' in the dataset are being displayed > in > the > next column , which I dont want that way. I want to retain any commas > which > are present in my dataset. > How do I handle such a scenario? > > Thanks > Deepa
Well if your DataTable is in a Dataset with no other tables, then it would
look something like this:
myDataset.tables[0].DefaultView.Sort = "Name Of Column You Want To Sort By"
See if that works for ya.
See this article for more info: http://msdn.microsoft.com/library/de...tviewtopic.asp
Kevin
"Deepa" <De***@discussions.microsoft.com> wrote in message
news:FB**********************************@microsof t.com... Thanks dude. Just curious if you can help me with something else. I have this dataset am converting into a csv file. Before I write to the output.csv I want to sort the values of the dataset in ascending order. I just have one single table in my dataset. I have the dataset ready, i mean to say am not making any connection to the database to populate the dataset. I have it as an xml dataset file. And am just saying ds.ReadXml(the xml file path) Before I loop thru the dataset, I want to sort it. Any ideas?
thanks Deepa
"Kevin Thomas" wrote:
You don't have to worry about which values have a comma or not. If the field is a text field (or you want it treated as such by Excel) just enclose it in quotes. You might have a row that ends up looking like:
"abcdef", "23klk,23,23", "eeeejjj","eee,t,r", 9,5
So you see, you put quotes around all your text fields. If one ends up with a comma in it, Excel will ignore it because it's in quotes.
Kev
"Deepa" <De***@discussions.microsoft.com> wrote in message news:9F**********************************@microsof t.com... > Kevin > I tried using the tab and the pipe delimiters but the resulting output > file > when viewed in excel isnt the same as i want it.(similar to a csv). > I thought of the double quotes but am not able to figure out how I > write > the > code to see what values in the dataset have a comma or not. > Would appreciate a response to this. > > Thanks > Deepa > > "Kevin Thomas" wrote: > >> You could do a couple things. If you put quotes around your text >> (called >> text qualifier), "A,B,C" then Excel will ignore the commas within the >> quotes. Another choice is to use a deliminator other than a comma, >> such >> as >> a TAB or a pipe. >> >> Kevin >> >> "Deepa" <De***@discussions.microsoft.com> wrote in message >> news:16**********************************@microsof t.com... >> >I am writing a console app in c# wherein am converting a dataset into >> >a >> >CSV >> > file. It works fine. But I have some values in the dataset which >> > have a >> > comma >> > within(eg. A,B,C). When I view the CSV file in Excel, the multiple >> > values >> > which are separated by the 'comma' in the dataset are being >> > displayed >> > in >> > the >> > next column , which I dont want that way. I want to retain any >> > commas >> > which >> > are present in my dataset. >> > How do I handle such a scenario? >> > >> > Thanks >> > Deepa >> >> >>
On Fri, 11 Mar 2005 12:03:04 -0800, "Deepa"
<De***@discussions.microsoft.com> wrote: I am writing a console app in c# wherein am converting a dataset into a CSV file. It works fine. But I have some values in the dataset which have a comma within(eg. A,B,C). When I view the CSV file in Excel, the multiple values which are separated by the 'comma' in the dataset are being displayed in the next column , which I dont want that way. I want to retain any commas which are present in my dataset. How do I handle such a scenario?
Thanks Deepa
For all you ever wanted to know about CSV files, have a look at http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm
rossum
--
The ultimate truth is that there is no Ultimate Truth
You forgot to mention what to do when there's quotes in the data. You'd
need to double them up as an escape.
The other option is to use my csv parser, http://www.geocities.com/shriop/index.html , or one like it, which
handles all of this for you and can write all data directly from a
DataTable.
Thanks Kevin,will try doing that
"Kevin Thomas" wrote: Well if your DataTable is in a Dataset with no other tables, then it would look something like this:
myDataset.tables[0].DefaultView.Sort = "Name Of Column You Want To Sort By"
See if that works for ya.
See this article for more info: http://msdn.microsoft.com/library/de...tviewtopic.asp
Kevin
"Deepa" <De***@discussions.microsoft.com> wrote in message news:FB**********************************@microsof t.com... Thanks dude. Just curious if you can help me with something else. I have this dataset am converting into a csv file. Before I write to the output.csv I want to sort the values of the dataset in ascending order. I just have one single table in my dataset. I have the dataset ready, i mean to say am not making any connection to the database to populate the dataset. I have it as an xml dataset file. And am just saying ds.ReadXml(the xml file path) Before I loop thru the dataset, I want to sort it. Any ideas?
thanks Deepa
"Kevin Thomas" wrote:
You don't have to worry about which values have a comma or not. If the field is a text field (or you want it treated as such by Excel) just enclose it in quotes. You might have a row that ends up looking like:
"abcdef", "23klk,23,23", "eeeejjj","eee,t,r", 9,5
So you see, you put quotes around all your text fields. If one ends up with a comma in it, Excel will ignore it because it's in quotes.
Kev
"Deepa" <De***@discussions.microsoft.com> wrote in message news:9F**********************************@microsof t.com... > Kevin > I tried using the tab and the pipe delimiters but the resulting output > file > when viewed in excel isnt the same as i want it.(similar to a csv). > I thought of the double quotes but am not able to figure out how I > write > the > code to see what values in the dataset have a comma or not. > Would appreciate a response to this. > > Thanks > Deepa > > "Kevin Thomas" wrote: > >> You could do a couple things. If you put quotes around your text >> (called >> text qualifier), "A,B,C" then Excel will ignore the commas within the >> quotes. Another choice is to use a deliminator other than a comma, >> such >> as >> a TAB or a pipe. >> >> Kevin >> >> "Deepa" <De***@discussions.microsoft.com> wrote in message >> news:16**********************************@microsof t.com... >> >I am writing a console app in c# wherein am converting a dataset into >> >a >> >CSV >> > file. It works fine. But I have some values in the dataset which >> > have a >> > comma >> > within(eg. A,B,C). When I view the CSV file in Excel, the multiple >> > values >> > which are separated by the 'comma' in the dataset are being >> > displayed >> > in >> > the >> > next column , which I dont want that way. I want to retain any >> > commas >> > which >> > are present in my dataset. >> > How do I handle such a scenario? >> > >> > Thanks >> > Deepa >> >> >> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jack |
last post by:
Hi,
I have form where one has to input officer's salary along with other data.
The officer's salary field is tied to a currency field in backend Access.
Right now folks enter numbers e.g....
|
by: Yama |
last post by:
Hi,
I am looking to create a report comma delimited on a click of a button.
Explanantion:
1. Get from the database: "SELECT * FROM Customers WHERE Region = 'CA'"
2. Use either DataReader or...
|
by: Deepa |
last post by:
I am writing a console app in c# wherein am converting a dataset into a CSV
file. It works fine. But I have some values in the dataset which have a comma
within(eg. A,B,C). When I view the CSV file...
|
by: bonehead |
last post by:
Greetings,
I'm using the DoCmd.TransferText method to export the results of a MS
Access query to a csv file. The csv will then be used to load an Oracle
table.
In other systems such as TOAD...
|
by: Avi |
last post by:
I need to create a text file that has the data from the 10 tables in
the database. The number of fields in the tables exceeds 255 and so I
cannot make a new table with all the fields and then...
|
by: =?Utf-8?B?RXJpY2E=?= |
last post by:
I am trying to dynamically create a javascript link. But, I get the following
error:
BC32017: Comma, ')', or a valid expression continuation expected.
Here is the line I try creating the...
|
by: Matthias Neubauer |
last post by:
Hi!
I am a C++ newbie and I'd like to trace the evaluation of some
expressions of my programs. I tried to use the comma operator for
that, but failed. I used a simple code substitution for...
|
by: s4lin |
last post by:
problem is pagination not retaining data field
i have form with general data field, and i need to select some option which is store in database, so i open another page with retrieving data from...
|
by: nigel |
last post by:
Hi,
I'm using VBA to export data from a table direct to a CSV file
DoCmd.TransferText acExportDelim, , "ExportTable", filePath
this produced a file with COMMA separated values,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
| |