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

How Do I Kill Non-Printable Characters?

Good evening all,

I have an annoying query regarding non-printable characters. I am
undertaking data validation on a very large CSV file retrieved from a
SQL Database, anything on the other side of the file retrieval is
totally out of my control. Unfortunately, there has been some issue in
the database which has meant that in large numbers of ASCII CHAR(0) has
been included in some of the CSV fields. This has resulted in my data
validation collapsing.

I have tried reading each character of the text file to remove the
occurrences of CHAR(0) with no success, I am guessing because when
importing the file through a StreamReader there are too many
occurrences.

My question is whether there is another way to read a file so that I can
recognise and kill all occurrences of CHAR(0). I am guessing if I read
the file as Hexadecimal it would work, but I have been unable to find
the native .NET method to do this; if it exists.

I have tried StreamReader and BinaryReader (I have no idea why I choose
to try this).

I am using VB.NET 2003.

Thanking you in advance!

Yours sincerely,

William Foster

*** Sent via Developersdex http://www.developersdex.com ***
Dec 2 '06 #1
2 2047
William,

Are you sure that this simple code is not working

\\\
Dim str As String = "I am from here " & Chr(0) _
& "not readable" & Chr(0) & " anymore"
MessageBox.Show(str.ToString)
str = str.Replace(Chr(0), "")
MessageBox.Show(str.ToString)
///

be sure that you set the resultvalue.

Cor
"William Foster" <no****@devdex.comschreef in bericht
news:ON**************@TK2MSFTNGP02.phx.gbl...
Good evening all,

I have an annoying query regarding non-printable characters. I am
undertaking data validation on a very large CSV file retrieved from a
SQL Database, anything on the other side of the file retrieval is
totally out of my control. Unfortunately, there has been some issue in
the database which has meant that in large numbers of ASCII CHAR(0) has
been included in some of the CSV fields. This has resulted in my data
validation collapsing.

I have tried reading each character of the text file to remove the
occurrences of CHAR(0) with no success, I am guessing because when
importing the file through a StreamReader there are too many
occurrences.

My question is whether there is another way to read a file so that I can
recognise and kill all occurrences of CHAR(0). I am guessing if I read
the file as Hexadecimal it would work, but I have been unable to find
the native .NET method to do this; if it exists.

I have tried StreamReader and BinaryReader (I have no idea why I choose
to try this).

I am using VB.NET 2003.

Thanking you in advance!

Yours sincerely,

William Foster

*** Sent via Developersdex http://www.developersdex.com ***

Dec 2 '06 #2
Cor,

Thanks for that, I have no idea why it wasn't working when I did it.

Yours sincerely,

William Foster

*** Sent via Developersdex http://www.developersdex.com ***
Dec 2 '06 #3

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

Similar topics

6
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with...
5
by: Blatwurst | last post by:
I'm trying to implement a simple server in C#. I want to do the classic thing of spinning off a thread that just blocks in a Socket.Accept() call until a request comes in. At that point, the...
6
by: ujjc001 | last post by:
Hello all. I have many connections that are sleeping. I can right click, kill, up to 2 at a time. It takes about 20 seconds to kill it. Is that normal? I tried to make a stored procedure to...
7
by: Mal Reeve | last post by:
Hi, I am using the KILL command to either empty a directory, or delete a file. How do I test for the files existence first, since attempting to delete a non-existent file causes an error. I...
1
by: Manfred Braun | last post by:
Hi All, I am writing a tool, which should monitor some exe-processes, which are not very solid. Th main function is to re-start them, if they hung, but this is complicated. I can detect things...
10
by: I. Myself | last post by:
Suppose we spawn a child process with Popen. I'm thinking of an executable file, like a compiled C program. Suppose it is supposed to run for one minute, but it just keeps going and going. Does...
4
by: Richard Rossel | last post by:
Hi Fellows, I have a problem with process termination. I have a python code that apache runs through a django interface. The code is very simple, first, it creates a process with the...
9
by: Phoe6 | last post by:
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code # This...
3
by: spectrumdt | last post by:
Hello. I am running Fedora Linux and KDE, using the Konsole command line. When coding Python, I regularly make a bug causing my program to not terminate. But how do I kill the non-terminating...
5
by: Thomas Christensen | last post by:
This issue has been raised a couple of times I am sure. But I have yet to find a satisfying answer. I am reading from a subprocess and this subprocess sometimes hang, in which case a call to...
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$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

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.