|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How Do I Kill Non-Printable Characters?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 *** 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 Show quoteHide quote "William Foster" <nospam@devdex.com> schreef in bericht news:ONBHgLhFHHA.3668@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 *** 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 ***
best way to learn Windows Forms
Upgrading Access 97 application to dotNet For loop variable date Merging two tables in Dataset? I only want to get the matching info based on the two key fields Working with a database How to set an objects property using Reflection How do you start an assembly dynamically with constructors Enter Key vs. Tab Key Q: VS2005 Drag and Drop controls during runtime in Windows App |
|||||||||||||||||||||||