TextFieldParser - reading tab delimited file

VB.NET

    Sponsored Links

    Next

  • 1. Best way to open windows forms
    Hi, I have a multi form windows application but when i open new forms they do not load up "crisply", they open bit by bit as the items are drawn. What is the best way to open the form so that the entire form is drawn/shown at the same time. I hope this post makes sense, it is a bit hazey I'm affraid. Thanks for any help Steve.
  • 2. DotNet inherently more processor intensive or just inefficent?
    I had occasion to unearth one of my old VB6 projects today and had forgotten how blazingly fast it runs compared to VB.Net. Naturally non-UI code is faster in DotNet, but everything else, all the GUI stuff is just plain slow as molasses compared to VB6. I strongly suspect GDI+ is mostly to blame; regardless, is speed acknowledged as a problem? Is it expected to get fixed or get slower in the next release? Bob
  • 3. Server and Client Deployment
    Hi All, I have developed one application software, and done the deployment as well... by clicking Setup.exe, my application software is able to install. after installation is done, then click the XXX.exe, then able to run the application. my problem is that...... if i got 10 users want to run this application, i got to do the same installtion 10 times on each PC.... i am wondering if anyone know how to use Visual Baisc DotNet to create a light client installation. What i mean here is that all the DLL file, i want to stored at server....and my clients only the interface... for exmaple.....SQL 2000 or other ERP software.... SQL 2000 we can install SQL server on A, but the SQL Client on B, then B still have access to A server, to control...... ERP most ERP software always got 1 server installtion and clients installation....... server side always buggy and heavy, but clients workstation side always light and easy for my application software...i want to do the same as well.... install the whole application on server, later for all other client, i just need to run another setup for clients workstation, then that the application will get everything from server pls advise...thank you....
  • 4. Cannot run VB.net web application from debug menu (F5)
    Where is the IIS server? Is it on the same machine was Visual Studio .NET? If not you may have permissions errors. I gave up on the difficulty of doing this and slowness and just run both on the same machine. If you do have 2 machines and one with IIS, and have control of it, you must install some software from VS Studio .NET CD on that machine to make Debugging work--I think and there is also a users group and permissions and such. Like I said, easier to run both from same machine. HTH, Shane "TomAmsden" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... > Error "Server does not support debugging of ASP.Net". Asks me to reload VS.Net server components. Have done this 3 times to no avail. Having difficulties getting through a relatively simple correspondence course 'VB.Net' in a weekend. > > Something is not installed correctly but I certainly cannot find it. > Any help would be appreciated
  • 5. CultureInfo
    Hi I've been taken by surprise when I realized that MyDouble.ToString() actually formats the string based on the local settings of the machine it was installed on (rather than using InvariantCulture settings by default). This represents a problem for my app, since this data is converted back to doubles at some later stage and since the client and the server may have different regional settngs. Is there a way to set the culture in an application 'globally', rather the using MyDouble.ToString(System.Globalization.CultureInfo.InvariantCulture) all over the place? Thanks for any hints. Urs

TextFieldParser - reading tab delimited file

Postby al jones » Fri, 22 Sep 2006 20:34:05 GMT

I using textfieldparser to read a data file. which contains, for example:

Amond Szegi	Amondo Szegi
andr nossek	Andr Nossek
 Characte	Character

Note the vowels with diacriticals and the copyright symbol - it is dropping
these (and other similar) characters which fall outside ascii range
(apparently)

The code is simple and looks like:
        Using MyReader As New TextFieldParser(Application.StartupPath &
"\designers.txt")
            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.CommentTokens = New String() {"#"}
            MyReader.Delimiters = New String() {vbTab}
            MyReader.TrimWhiteSpace = True
            Dim currentRow As String()
            intElement = 0
            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    If Microsoft.VisualBasic.Left(currentRow(0), 7) =
"UNKNOWN" Then
                        strUnknownDesigner = currentRow(1)
                        Continue While
                    End If
                    arDesigner(intElement, 0) = currentRow(0)
                    arDesigner(intElement, 1) = currentRow(1)
                    arDesignerCounter(intElement) = 0
                    intElement += 1
                Catch ex As MalformedLineException
                    MsgBox("Designer Line " & ex.Message & "is not valid
and will be skipped.")
                End Try
            End While
        End Using

I can see any reason in the documentation for it dropping copyright or
the French and German (etc vowels with accents.

Comments or suggestions anyone??

Thanks //al

Re: TextFieldParser - reading tab delimited file

Postby Andrew Morton » Fri, 22 Sep 2006 21:02:59 GMT


> Characte Charact>r
>>
> Note the vowels with diacriticals and the copyright symbol - it >s
> dropping these (and other similar) characters which fall outsi>e
> ascii range (apparently)

It appears to be an encoding problem where the file uses (I'm guessing) 
ISO-8859-1 or maybe Windows-1252 whereas the .NET framework defaults to 
Unicode. Does a TextFieldParser have a setting for that (or have a 
.BaseClass that does)?

Or perhaps you can arrange for the file to be encoded with Unicode?

Andrew 



Re: TextFieldParser - reading tab delimited file

Postby al jones » Sat, 23 Sep 2006 02:31:52 GMT





>> AmondSzegi Amondo Szegi
>>> andrnossek AndrNosse>>
>> Characte Charact>>
>> Note the vowels with diacriticals and the copyright symbol - it >>
>> dropping these (and other similar) characters which fall outsi>>
>> ascii range (apparentl>)
> It appears to be an encoding problem where the file uses (I'm guessing> 
> ISO-8859-1 or maybe Windows-1252 whereas the .NET framework defaults t> 
> Unicode. Does a TextFieldParser have a setting for that (or have > 
> .BaseClass that does>?
> Or perhaps you can arrange for the file to be encoded with Unicod>?
> Andrew

Possibly my confusion is from the fact that I maintain these files (there
are three of them) within VS 2005 so I would have epected them to be
unicode. The characters exist within the files (the three line examples are
cut & paste from the file itself) so I don't understand why reading them
would literally eliminate the characters.

I've been over the TextFieldParser docs and see nothing that indicates that
it shouldn't take the data as presented.

Re: TextFieldParser - reading tab delimited file

Postby Jeff Glatt » Sun, 24 Sep 2006 01:42:40 GMT

Try OrchidGrid control, which can pase/import data from delimited files.






Similar Threads:

1.How to read a Tab Delimited text file in to a Flexgrid without using .Clip Method

I  need to Read Tab limited Txt file in other controls, on a form,
convert to PDF .... etc etc

I saw Your eg. in a previous post...its very good..

another problem the flexgrid displays a special charecter in the first
col  if .Clip method is used.
Further i should  be able to find the no of cols and rows in the Txt
file . to re create the file to any suitable  control .

Thank You

2.How to read a Tab Delimited text file in to a Flexgrid without using .Clip Method

How to read a Tab Delimited text file in to  a Flexgrid without using
.Clip Method

3.Problem reading Unicode from a tab-delimited file

Hi,
I have a spreadsheet that contains multiple languages. Per project
requirements I have saved this speadsheet in a tab-delimted format
using Excel 2007. I have been able to pretty much get all the
charaters correct when reading the file. I will also have to parse
Japanese from this, which I have not been able to do. I cannot read
the 3 byte characters from the file correctly for some reason. I have
an example here showing 2 characters for simplicity.

??

I get the correct value for ? but not for ? The value of ?should be
2019, instead I getting something that just displays a box in the
debugger, some value around 65k.
Note in the code snippet below, If I pass the unicodeString to the
foreach (Byte b in encodedBytes)
it works perfectly, outs the correct values for the charaters.. I have
a tab-delimted file that contains the same characters. When I open
that file and reead from it, the ?is correct, but the ?is not.
Likewise for the Japanese characters I am tring to read. Almost seems
like the issue is the file open() or the readline().
Any help and code examples would be appreciated.
Thanks
Jeff




 String unicodeString = " ???";;
            // Create a UTF-8 encoding.
            UTF8Encoding utf8 = new UTF8Encoding();
            // determine whether fileName is a file
            if (File.Exists(fileName))
            {
                     // obtain reader and file contents
                    StreamReader stream = new StreamReader(fileName);
                    // Open the file to read from.
                    using (StreamReader sr = File.OpenText(fileName))
                    {

                        while( sr.ReadLine() != null )
                        {

                            // Encode the string.
                            Byte[] encodedBytes = utf8.GetBytes
(unicodeString);
                            Console.WriteLine();
                            Console.WriteLine("Encoded bytes:");
                            foreach (Byte b in encodedBytes)
                            {
                                if (b != 9)
                                {
                                    Console.Write("[{0}]", b);
                                }
                            }

                        }

                    }

            } // end if

4.Reading tab delimited file

I have a file that is tab delimited and has no header row with column 
headings. What is the best method for reading this data into a dataset?

5.Reading Tab Delimited Data With Imbedded Double Quotes

I can't get the Microsoft Jet OLEDB 4.0 driver to read a tab delimited 
text file that has double quotes imbedded in the data. For example

Field1 | Field2 | Field3
Bob | Pant Size 34" Waist | 22

(I'm using a vertical bar here for the tab)

Field2 will contain: Pant Size 34
Field3 will contain: Waist

I have a schema.ini

[MyFile.txt]
ColNameHeader=True
Format=TabDelimited
MaxScanRows=25
CharacterSet=OEM

How do I get it to read the double quote?

Tom

6. Reading Tab Delimited Text thorugh VB6

7. Reading a delimited text file into Access 2000 mdb file with VB 6.0

8. Save a excel file as a TAB delimited text file



Return to VB.NET

 

Who is online

Users browsing this forum: No registered users and 46 guest