473,396 Members | 2,037 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,396 software developers and data experts.

Readind a texte

Hey guys
i want to read from file that contains the following data:
-------------------
A1/EXT "BK82 LB73 21233" 105 061018 1804
EXTERNAL ALARM
COOLING ALARM
A1
------------------
the thing is that i want to read each part alone
and stores it in a database
any hint for that?
PS: how to read the double quote ?
Regards,
Oct 23 '06 #1
1 1104
xtab
6
One of the best ways to get round the problem of referring to double quotes is to use its ASCII value instead. This is 34.

So as an example of the kind of thing you want to do (but without saving to a database - just displaying what it finds within the quotes), you can use something like this:

Expand|Select|Wrap|Line Numbers
  1.         Dim src As String = "C:\Parts.txt"  ' name of file
  2.         Dim sr As New IO.StreamReader(src)
  3.         Dim checkStr As String = String.Empty
  4.         Dim result As New ArrayList
  5.         Do While Not sr.Peek = -1
  6.             checkStr = sr.ReadLine
  7.             If checkStr.Contains(Chr(34)) Then
  8.                 Dim first As Integer = checkStr.IndexOf(Chr(34)) + 1
  9.                 Dim last As Integer = checkStr.LastIndexOf(Chr(34))
  10.                 result.Add(checkStr.Substring(first, last - first))
  11.             End If
  12.         Loop
  13.  
  14.         '  Display for demo purposes
  15.         For Each s As String In result
  16.             Console.WriteLine(s)
  17.         Next
This code will store the values from between the quotes in any line that has two sets of double quotes in it.
Of course, to make it robust you would need to build in Exception Handling for cases e.g. where there is only one double quote. But if the layout of the data is always as you posted, then the above code will work fine.
Oct 24 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Agathe | last post by:
Bonjour, Je souhaite insérer dans une table MySQL des données provenant d'un fichier texte grâce à un script PHP. Mon fichier porte l'extension "txt" et les données sont séparées par des ";'. ...
9
by: François Pinard | last post by:
Hi, people. I hope someone would like to enlighten me. For any application handling Unicode internally, I'm usually careful at properly converting those Unicode strings into 8-bit strings before...
3
by: Québec | last post by:
Hi, I am new to Opera and I am quite surprised. I opened the javascript console: nothing. Nothing appears except the bargroung image in opera. <SCRIPT LANGUAGE="JavaScript"> var input =...
1
by: ernond_paul | last post by:
Hi, I'm trying to have a box with "overflow: auto" in order to print only a few part of a text. I want to have a scroll for this box : that's work fine. But my problem is when I use the Wheel...
0
by: Do Re Mi chel La Si Do | last post by:
Open-Office 2.0 bêta-2 français pour Windows (en fait, la 1.9.125 ) est sortie. Vous la trouverez là : ...
1
by: eric lecocq | last post by:
Salut, mon problème est le suivant: j'ai une DB avec des liens vers des fichiers texte. je voudrais savoir comment je fais pour pouvoir dire à Access qu'un champ de type date peut être vide ?...
1
by: Dexter | last post by:
I have an <imgtag like <img alt=none src=http://somesite.com/mypage.aspx> embedded into an email message. The request returns a gif image to the browser. What I am unable to do is to access the...
2
by: Olivier | last post by:
Dear all, Here is a sample of my code: ---------------------------------------------- void message_is(gchar *ff, int d, gchar *o){ gchar *texte = NULL; texte = g_malloc(256);...
9
by: =?iso-8859-1?q?C=E9dric_ELLENA?= | last post by:
Hi, I need to make a little c# program which copies a text into the clipboard and that pastes this data into the active window. I copy the data like this Clipboard.SetText("mystring"); ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.