[Tutor] newbie question
Wilhelmsen Jan
Jan.Wilhelmsen@bilia.no
Fri Jul 18 07:29:02 2003
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C34D1F.710DA370
Content-Type: text/plain
Hi!
I'm fairly new to programming so I have to ask a simple question.
I have a text file witch contains some constants that I will use later when
parsing some other text files.
File 1:
40 444
60 380
68 950
70 950
What I have to do is to check to values in column 1(v1) against a value in
another a text string(v2), if match then v1 = v2.
I know have to do this by opening the file and do a search and then close
the file.
But since this check will occur numerous times I thought maybe it's better
too read the file in memory once and that's it.
Can I make sort of a "table" (t1) with objects (column1) that has a
value(column2).
Then check this "table" when parsing the other text file?
Hope someone can give me some tip about this.
Regards
Jan Wilhelmsen
-------------------------------------------------------------------------------
This verifies that this e-mail has been scanned for virus and deemed virus-free
according to F-secure Content Scanner 5.0
Fri, 18 Jul 2003 13:26:33 +0200 GMT
-------------------------------------------------------------------------------
------_=_NextPart_001_01C34D1F.710DA370
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" xmlns:w=3D"urn:sc=
hemas-microsoft-com:office:word" xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Dus-ascii">
<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 10">
<meta name=3DOriginator content=3D"Microsoft Word 10">
<link rel=3DFile-List href=3D"cid:filelist.xml@01C34D30.54B2D180">
<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:DoNotRelyOnCSS/>
</o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:GrammarState>Clean</w:GrammarState>
<w:DocumentKind>DocumentEmail</w:DocumentKind>
<w:HyphenationZone>21</w:HyphenationZone>
<w:EnvelopeVis/>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]-->
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
{margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
span.EpostStil17
{mso-style-type:personal-compose;
mso-style-noshow:yes;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;
font-family:Arial;
mso-ascii-font-family:Arial;
mso-hansi-font-family:Arial;
mso-bidi-font-family:Arial;
color:windowtext;}
span.GramE
{mso-style-name:"";
mso-gram-e:yes;}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
/* Style Definitions */=20
table.MsoNormalTable
{mso-style-name:"Vanlig tabell";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";}
</style>
<![endif]-->
</head>
<body lang=3DNO-BOK link=3Dblue vlink=3Dpurple style=3D'tab-interval:35.4pt=
'>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'>Hi!<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span style=3D'font-size:1=
0.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>I'm fairly new to
programming so I have to ask a simple question.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>I have a text file witch
contains some constants that I will use later when parsing some other text
files.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'>File 1:<o:p></o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span></=
font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'>40<span style=3D'mso-tab-c=
ount:
1'> </spa=
n>444<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'>60<span style=3D'mso-tab-c=
ount:
1'> </spa=
n>380<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'>68<span style=3D'mso-tab-c=
ount:
1'> </spa=
n>950<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'>70<span style=3D'mso-tab-c=
ount:
1'> </spa=
n>950<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span></=
font></p>
<p class=3DMsoNormal><font size=3D1 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
8.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span></=
font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>What I have to do is to c=
heck
to values in column 1(v1) against a value in another a text <span class=3DG=
ramE>string(</span>v2),
if match then v1 =3D v2.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>I know have to do this by=
opening
the file and do a search and then close the file.<o:p></o:p></span></font><=
/p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>But since this check will=
occur
numerous times I thought maybe <span class=3DGramE>it's</span> better too
read the file in memory once and that's it.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>Can I make sort of a "tab=
le"
(t1) with objects (column1) that has a <span class=3DGramE>value(</span>col=
umn2).
<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>Then check this "table"
when parsing the other text file?<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>Hope someone can give me =
some
tip about this.<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'>Regards<o:p></o:p></span>=
</font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DEN-GB style=
=3D'font-size:
10.0pt;font-family:Arial;mso-ansi-language:EN-GB'><o:p> </o:p></span><=
/font></p>
<p class=3DMsoAutoSig><font size=3D3 face=3D"Times New Roman"><span lang=3D=
EN-GB
style=3D'font-size:12.0pt;mso-ansi-language:EN-GB;mso-no-proof:yes'>Jan
Wilhelmsen<o:p></o:p></span></font></p>
<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span lang=3DE=
N-GB
style=3D'font-size:12.0pt;mso-ansi-language:EN-GB'><o:p> </o:p></span>=
</font></p>
</div>
<FONT SIZE=3D3><BR>
<BR>
---------------------------------------------------------------------------=
----<BR>
This verifies that this e-mail has been scanned for virus and deemed virus-=
free <BR>
according to F-secure Content Scanner 5.0<BR>
Fri, 18 Jul 2003 13:26:33 +0200 GMT<BR>
---------------------------------------------------------------------------=
----<BR>
</FONT>
</body>
</html>
------_=_NextPart_001_01C34D1F.710DA370--