Microsoft.VB.FileIO.TextFieldParser Unable To Parse Mac Unicode File With Text Qualifiers Properly?
Sep 15, 2010
I am trying to use Microsoft.VisualBasic.FileIO.TextFieldParser for parsing any format of tab delimited text file that user may have and show the data in web page in tabular fashion.I have sample tsv file with text qualifiers such as quotes saved in different encoding styles for different platforms such as pc, unix, mac saved using textpad. and I am trying to parse these using TextFieldParser. It works for all PC files but fails for mac.
I am using Microsoft.VisualBasic.Fileio.TextFieldParser to parse a CSV file that was created with Excel 2003. The parser is working great with the exception that it is converting extended ascii values to question marks! So if the file content was:
± 3 The TextFieldParser is returning ? 3
I have tried all of the encodings in the System.Text.Encoding package with no luck. I thought I had it with UTF7 but it was dropping other characters like replacing the + sign with a space.
I use VS 2008, .net 3.5, C# projects. I need do the same functionally like Microsoft.VisualBasic.FileIO.File System.DeleteDirectory. Anyone says referencing the Microsoft.VisualBasic is often undesirable from within C#. Any association with VB from within C# code strikes me as undesirable. Using FileSystem class, this is a perfectly fine solution, but I prefer not references Microsoft.VisualBasic library. That one I would avoid.
Is there a set function in vb.net that allows you to read a delimited file with text qualifiers? In the past I have used the split command but that does not allow you to take into account the text qualifiers.
I make a program that want to read texts into collection class. The program need to know whether the text file is in unicode or not. What is the vb.net code to test whether a text file is in unicode or not? Is there a vb.net code that allow me to read text file without worrying whether it's unicode or not?
I want to use the Linkshare helper in the Microsoft.Web.Helpers dll. I added the reference to my project but if attempt to use it in the vbhtml file Visual studio underlines it with a blue squiggly and tells me it is inaccessible blah blah. I even added references to those webmatrix dlls as described here[url]...
I ran across my first unicode data, and I am not sure what to do with it. I read the unicode text from a binary file using the ReadBytes method, because ReadChars threw an exception when it tried it. Well, long story short, I have found a way to work with the data, I can convert it using a small Function I wrote, which goes something like this: [Code] And this works wonderfully. It just throws away anything not in the ASCII range, including the BOM at the start of the unicode data.
But I would guess that this method is not very universal and probably not the best way. Are there any VB functions available to do this sort of thing? I was able to find something called Text.Encoding, but there didn't seem to be a reverse of that not that I found anyhow. Any ideas?
I occasionally have to search a very large text file as a troubleshooting step. The file is continuous text (with spaces between much of the text) but almost everything is date/time stamped. The text is actually messages between two machines so I'd like to insert a line break after every message so that I can follow the protocol exchange. Thre are also a few key words that I'd like to again, separate with a line break.
I occasionally have to search a very large text file as a troubleshooting step. The file is continuous text (with spaces between much of the text) but almost everything is date/time stamped. The text is actually messages between two machines so I'd like to insert a line break after every message so that I can follow the protocol exchange. Thre are also a few key words that I'd like to again, separate with a line break
I am trying to pull out a row of comma seperated fields from a text file. I have a combo box which pulls a product number, and what I want it to do it after you select the item in the combo box it will search through the text file and pull everything in that row?
I am using VB.NET 2005 (if that matters).I need to parse a text (log) file in which to process lines like:
Program Up at: Tue Jun 24 11:32:53.656 2008 - TerrificProgram.exe <some lines here which I ignore> 0.00:24:16 - Emergency Stop! <more lines to ignore> Program Down at: Thu May 29 22:22:56.000 2008
where the 0.0:24:16 is the offset in TimeSpan format (d.hh:mm:ss) relative to the 'Program Up at" datetime.The 'Program Up at: <date/time>' line I successfully detect (in another function which works) and as a result a set a Boolean flag that I am in a valid <Up> - <Down> sequence and I also set a Start-up DateTime var to which to add the offsets later.
The task is to convert the TimeSpan at the beginning of the 'Emergency stop' line to a regular DateTime expression and to write the converted line to another log-file.Simple, isn't it?The function I use for the above purpose is:
Private Function IsTimeSpan(ByRef InputLine As String, ByVal ProgStart As Boolean, ByVal DTofProgStart As DateTime, ByRef NewDateTime As DateTime) Dim iLine As String = InputLine Dim Index As Integer = iLine.IndexOf(" ")
What I am doing is I pass each line ('InputLine' parameter) from the original log-file to the function together with the 'in <up>-<down>' flag ('ProgStart' parameter'), the start ot program DateTime (in the 'DTofProgStart') and I want the NewDate to hold the real datetime of Emergency event occurence (not its offset).
What happens is that I successfully detect the lines of interest but the NewDateTime is not updated (though 'ts' is in the correct format and the assignment 'NewDateTime = DTofProgStart' correctly assigns the passed value).Another curious thing is that the line
# TAG NAME = is saved to a file using the code below but when I load that same file back into a RichTextbox Control using additional code below, I get inconsistent results as I try to parse the text. Has anyone else had this problem?'Save the contents of the RichTextBox into the file.richTextBox.SaveFile(saveFile1.FileName, RichTextBoxStreamType.RichText);'Retrieve contents of File into RichTextBox control Dim logData As String logData = System.IO.File.ReadAllText(path + "\" + filenname);
So I'm guessing it has something to do with the fact that I don't have office loaded on my computer. Now I have another laptop, with office that I loaded this project on, and it works fine. So do I have to load office on this computer, or can I just reference something?
I have to parse through a text file that is growing and currently is about 30MB, but it takes a long time for the stream reader to load it before It can loop through the lines. Is there a faster method other than the streamreader?
I'm running into a problem whenever I try to parse a text file by each line. I know I could use stream reader to read line by line but it is a lot easier to simply use split() and I would also like to know the reason why split() doesn't work.
For example, I created a file "test.txt" and filled it with the following text.
text1 text2 text3
then put the following code in the load event of the form (a button click would work the same).
I'm trying to use VB.NET to parse a very large plain text file (2 GB). It is a database and has a field delimiter of SOH and a record delimiter of STX. I want to separate the fields and records of the file.
I would normally read each line of a text file and then use the split function to separate out the fields. I can't use this approach as there isn't always a delimiter on every line.
Is there any way to read a file until STX is found (rather than one line at a time)?
I have a VB2010 project where I need to read a tab delimited 50MB file using Microsoft.VisualBasic.FileIO.TextFieldParser. This technique works fine until the reader encounters a Unicode character upon which it inserts the little square thingy. The obvious choice is to change the encoding of the reader to Unicode from the default. This would probably work fine but for most files but this one is fairly large and I get the error TextFieldParser is unable to complete the read operation because maximum buffer size has been exceeded. By the way this file can be read completely without the Unicode option. Making the file smaller or breaking it up really isn't an option. Is is possible to increase the buffer size or is there another way to read this data that places the data in fields like the textparser and allows unicode characters?
Year 1 mandatory COM137,Mathematics for Computing,20,2 COM140,Computer Technologies,1-2,20 COM147,Introduction to databases,1-2,20 Year 2
in here is where i am having the problem i don't know how to get all the information i need into one specific array element within an array.. i want to get the year and the module status added to the end of an array element
I'm currently busy coding a hangman game in VB.NET.As a wordlist, I have a textfile containing 1520 words, each one seperated by a new line. The best I could think of to get a random word is with a Randomize() function. Then getting the word from the line # which was randomly generated.
Is there any better way for me to extract the word from that random line? If not, what would be the delimiter I should use for this and how do I quickly change the breaklines into that new delimiter without resorting to Office?
Also, how can I use the textfieldparser to get the file from resources? When I tried using my.resources.filename instead of "filepath", it gave me an ArgumentException due to "invalid characters in the path".