473,225 Members | 449 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,225 software developers and data experts.

Triming extra characters ???

Dear all,

I have a csv file which as following output :
"REC00001.CSV","Pipe","25 x 2.5 mm","LP602","LP602","02/11/2004 15:15:04"

I need to remove from that string doucble quote char.

In order to read my file I use following code :

sRead = m_IOStream.ReadLine
'- as it is a CSV file format, we need to identify the separator
field and split the string in array for ready data

sRead = sRead.Trim(sTrimChar)

HOw to define my sTrimChar delimiter to remove double quote in my string.?
I have tried "''" but it fails

thnaks for your help
regards
serge
Jul 21 '05 #1
11 2267
Serge,

try the following:

sTrimChar = "\"";

Regards,
Michael

"serge calderara" <se************@discussions.microsoft.com> schrieb im
Newsbeitrag news:0B**********************************@microsof t.com...
Dear all,

I have a csv file which as following output :
"REC00001.CSV","Pipe","25 x 2.5 mm","LP602","LP602","02/11/2004 15:15:04"

I need to remove from that string doucble quote char.

In order to read my file I use following code :

sRead = m_IOStream.ReadLine
'- as it is a CSV file format, we need to identify the separator
field and split the string in array for ready data

sRead = sRead.Trim(sTrimChar)

HOw to define my sTrimChar delimiter to remove double quote in my string.?
I have tried "''" but it fails

thnaks for your help
regards
serge

Jul 21 '05 #2
mihael,

What effect does that syntax does ?
especailly the \ char, is it EScap sequence ?

I am using VB.net for your info
But I will give a try anyway

"Michael Groeger" wrote:
Serge,

try the following:

sTrimChar = "\"";

Regards,
Michael

"serge calderara" <se************@discussions.microsoft.com> schrieb im
Newsbeitrag news:0B**********************************@microsof t.com...
Dear all,

I have a csv file which as following output :
"REC00001.CSV","Pipe","25 x 2.5 mm","LP602","LP602","02/11/2004 15:15:04"

I need to remove from that string doucble quote char.

In order to read my file I use following code :

sRead = m_IOStream.ReadLine
'- as it is a CSV file format, we need to identify the separator
field and split the string in array for ready data

sRead = sRead.Trim(sTrimChar)

HOw to define my sTrimChar delimiter to remove double quote in my string.?
I have tried "''" but it fails

thnaks for your help
regards
serge


Jul 21 '05 #3
Be aware that the Trim function will only remove the characters from
the beginning and end of the string.

If you wish to remove all occurences of the quotation mark, try this:

sRead = sRead.Replace("""",String.Empty)

Note that the first argument above has 4 quotation marks.

There may be other ways to do this that have better performance.

Chris

Jul 21 '05 #4
Be aware that the Trim function will only remove the characters from
the beginning and end of the string.

If you wish to remove all occurences of the quotation mark, try this:

sRead = sRead.Replace("""",String.Empty)

Note that the first argument above has 4 quotation marks.

There may be other ways to do this that have better performance.

Chris

Jul 21 '05 #5
If you have a small budget, but at least a budget, my suggestion is to
actually buy a package to handle all this nastiness for you instead of
trying to guess at the proper handling because at best, you'll do it
very inefficiently, and at worse, you'll do it inefficiently and
incorrectly. As for the answer to your question, if you're just bound
and determined to do it wrong, split on a comma, then on each value in
the array, you'd want to trim ", but then replace "" with ". Even at
that, you're breaking atleast 3 rules of csv parsing.

Jul 21 '05 #6
Serge,

yes \ is a escape sequence in c#/c++. I think the way Chris does it is the
best. He's also correct that Trim() only trims the leading and trailing
characters. Sorry, I forgot that one...

Regards,
Michael

"serge calderara" <se************@discussions.microsoft.com> schrieb im
Newsbeitrag news:CA**********************************@microsof t.com...
mihael,

What effect does that syntax does ?
especailly the \ char, is it EScap sequence ?

I am using VB.net for your info
But I will give a try anyway

"Michael Groeger" wrote:
Serge,

try the following:

sTrimChar = "\"";

Regards,
Michael

"serge calderara" <se************@discussions.microsoft.com> schrieb im
Newsbeitrag news:0B**********************************@microsof t.com...
Dear all,

I have a csv file which as following output :
"REC00001.CSV","Pipe","25 x 2.5 mm","LP602","LP602","02/11/2004 15:15:04"
I need to remove from that string doucble quote char.

In order to read my file I use following code :

sRead = m_IOStream.ReadLine
'- as it is a CSV file format, we need to identify the separator field and split the string in array for ready data

sRead = sRead.Trim(sTrimChar)

HOw to define my sTrimChar delimiter to remove double quote in my string.? I have tried "''" but it fails

thnaks for your help
regards
serge


Jul 21 '05 #7
thanks chirs that works

serge
"Chris Dunaway" wrote:
Be aware that the Trim function will only remove the characters from
the beginning and end of the string.

If you wish to remove all occurences of the quotation mark, try this:

sRead = sRead.Replace("""",String.Empty)

Note that the first argument above has 4 quotation marks.

There may be other ways to do this that have better performance.

Chris

Jul 21 '05 #8
just for my knowlege, why 4 quaotation marks are required and not only the
single " ?
"Chris Dunaway" wrote:
Be aware that the Trim function will only remove the characters from
the beginning and end of the string.

If you wish to remove all occurences of the quotation mark, try this:

sRead = sRead.Replace("""",String.Empty)

Note that the first argument above has 4 quotation marks.

There may be other ways to do this that have better performance.

Chris

Jul 21 '05 #9
just for my knowlege, could you explain me why the proposiion of chris is not
suitable?

I means what rules are you talking about, I am interresting to know?

"shriop" wrote:
If you have a small budget, but at least a budget, my suggestion is to
actually buy a package to handle all this nastiness for you instead of
trying to guess at the proper handling because at best, you'll do it
very inefficiently, and at worse, you'll do it inefficiently and
incorrectly. As for the answer to your question, if you're just bound
and determined to do it wrong, split on a comma, then on each value in
the array, you'd want to trim ", but then replace "" with ". Even at
that, you're breaking atleast 3 rules of csv parsing.

Jul 21 '05 #10
Serge,

that's how vb.net escapes double quotes.

Regards,
Michael

"serge calderara" <se************@discussions.microsoft.com> schrieb im
Newsbeitrag news:D4**********************************@microsof t.com...
just for my knowlege, why 4 quaotation marks are required and not only the
single " ?
"Chris Dunaway" wrote:
Be aware that the Trim function will only remove the characters from
the beginning and end of the string.

If you wish to remove all occurences of the quotation mark, try this:

sRead = sRead.Replace("""",String.Empty)

Note that the first argument above has 4 quotation marks.

There may be other ways to do this that have better performance.

Chris

Jul 21 '05 #11
Trimming quotes from the beginning and end of a column will remove the
quotes even if they're supposed to be there, like on a column "Mary
said, ""Go away!""". Splitting on a comma will mess up columns with
commas in them, like "$100,000". Using ReadLine will mess up columns
that can contain carriage returns and new line characters in the data,
which is completely valid as long as they're contained in text qualifed
data using quotes. In quite a few instances, leading and trailing white
space in non text qualified data should be trimmed. These rules are
very valid, and are why I'd suggest not making your own csv parsing
routines, and instead just buying a parser where someone has already
done all this work for you, and most likely, a lot more efficiently
since they weren't under a deadline restriction to just get something
that kind of works out.

Here's a site that I consider pretty decent describing some of the de
facto standard rules of csv data.

http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm

Jul 21 '05 #12

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

Similar topics

4
by: Sidharta | last post by:
Hi all, how come this doesn't work????? # convert to unix new lines $text = preg_replace("/\r\n/", "\n", $text); # remove extra new lines $text = preg_replace("/\n+/", "\n", $text); is...
11
by: serge calderara | last post by:
Dear all, I have a csv file which as following output : "REC00001.CSV","Pipe","25 x 2.5 mm","LP602","LP602","02/11/2004 15:15:04" I need to remove from that string doucble quote char. In...
11
by: santosh | last post by:
Hi, A book that I'm currently using notes that the fgets() function does not return until Return is pressed or an EOF or other error is encountered. It then at most (in the absence of...
2
by: ricky | last post by:
Can anybody help with the function to get rid of extra characters in the file. I want to remove the string from the file.So i read from input file and pass the string say "john" if found dnt write...
1
by: dwaldman | last post by:
If i have the following recordset: <td><font size="1"><%= (rsT.Fields.Item("ASC_Name").Value) %></font></td> Which in live data displays Direct Wireless for example, how would I trim that...
5
by: acarroll | last post by:
We're currently using Sharepoint to pull data into Access, so our tables are linked. In our tables in Access we are getting extra characters (;#) in our data that needs to be removed. I'm assuming...
3
by: Michel Vanderbeke | last post by:
Hello, I would like to create a textbox with extra properties where I can choose if the textbox may contain only numbers, only letters, both, punctuation marks etc. Can anyone help me with tips...
2
by: =?Utf-8?B?YmJkb2J1ZGR5?= | last post by:
Hi, I am retrieving data from a binary field from a sql table and I am having a problem with extra characters being tacked onto the end. The thePass variable has some unknown spaces after it...
3
by: webqueen79 | last post by:
When I open up my asp code in an editor, I see TONS of extra whitespace between code lines which is making the editor bomb out because it takes so long to load all the lines. When I open up the asp...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
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
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"....

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.