By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

String Search in a LARGE text file

P: n/a
Here is a sniplet from a text file

game
name mapp
description "Mappy (US)
year 198
manufacturer "Namco
history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1. Mappy \n2. Hopping Mappy \n\n0.26 [Aaron Giles, Mirko Buffoni] \n\nBugs: \n- \"000\" is displayed on the highscore. If you get more than 30000 pts, it is displayed normally. This happens whether there are \"hiscore.dat\", hi file and cfg file or not. mappy37b4gre Fujix \n- In Mappy (both versions, mappy and mappyjp), if you insert at
rom ( name mp1-5.5b size 32 crc 56531268 sha1 2e356706c07f43eeb67783fb122bdc7fed1b3589 region proms offs 0
rom ( name mp1-6.4c size 256 crc 50765082 sha1
chip ( type cpu name M6809 clock 1536000
chip ( type cpu name M6809 clock 1536000
chip ( type audio name Namco_15XX
video ( screen raster orientation vertical x 224 y 288 aspectx 3 aspecty 4 freq 60.606060
sound ( channels 1
input ( players 2 control joy8way buttons 1 coins 2
dipswitch ( name "Cabinet" entry "Upright" default "Upright" entry "Cocktail"
I will have a variable containing the text string that matches the second line, "name mappy"

I would then like to find the line that begins with "video" and retrun one of the parameters that follow. It will be the one after the word "orientation" and it will be either "vertical" or "horizontal". I the want to set a variable to either "v" or "h" so I can apply my code. It's a pretty large text file, about 30MB. What is the best way to do this? The other day I was able to get a number to return that was the character number of the first string, but I got stuck after that

Thank you
John
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi JcRouse,

It is not important how you do it, when it is a file where the lines are
seperated by a vbcrlf or whatever, you can read them line by line using the
streamreader and than use in the routine where you read it the
string.indexof to find if what you are looking for exist.

I hope this helps, when you want more details, please reply?

Cor
Here is a sniplet from a text file:

game (
name mappy
description "Mappy (US)"
year 1983
manufacturer "Namco"
history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1.
Mappy \n2. Hopping Mappy \n\n0.26 [Aaron Giles, Mirko Buffoni] \n\nBugs: \n-
\"000\" is displayed on the highscore. If you get more than 30000 pts, it is
displayed normally. This happens whether there are \"hiscore.dat\", hi file
and cfg file or not. mappy37b4gre Fujix \n- In Mappy (both versions, mappy
and mappyjp), if you insert at rom ( name mp1-5.5b size 32 crc 56531268 sha1 2e356706c07f43eeb67783fb122bdc7fed1b3589 region proms offs 0 ) rom ( name mp1-6.4c size 256 crc 50765082 sha1
chip ( type cpu name M6809 clock 1536000 )
chip ( type cpu name M6809 clock 1536000 )
chip ( type audio name Namco_15XX )
video ( screen raster orientation vertical x 224 y 288 aspectx 3 aspecty 4 freq 60.606060 ) sound ( channels 1 )
input ( players 2 control joy8way buttons 1 coins 2 )
dipswitch ( name "Cabinet" entry "Upright" default "Upright" entry "Cocktail" ) )

I will have a variable containing the text string that matches the second line, "name mappy".
I would then like to find the line that begins with "video" and retrun one of the parameters that follow. It will be the one after the word
"orientation" and it will be either "vertical" or "horizontal". I the want
to set a variable to either "v" or "h" so I can apply my code. It's a pretty
large text file, about 30MB. What is the best way to do this? The other day
I was able to get a number to return that was the character number of the
first string, but I got stuck after that.
Thank you,
John

Nov 20 '05 #2

P: n/a
Hi JcRouse,

It is not important how you do it, when it is a file where the lines are
seperated by a vbcrlf or whatever, you can read them line by line using the
streamreader and than use in the routine where you read it the
string.indexof to find if what you are looking for exist.

I hope this helps, when you want more details, please reply?

Cor
Here is a sniplet from a text file:

game (
name mappy
description "Mappy (US)"
year 1983
manufacturer "Namco"
history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1.
Mappy \n2. Hopping Mappy \n\n0.26 [Aaron Giles, Mirko Buffoni] \n\nBugs: \n-
\"000\" is displayed on the highscore. If you get more than 30000 pts, it is
displayed normally. This happens whether there are \"hiscore.dat\", hi file
and cfg file or not. mappy37b4gre Fujix \n- In Mappy (both versions, mappy
and mappyjp), if you insert at rom ( name mp1-5.5b size 32 crc 56531268 sha1 2e356706c07f43eeb67783fb122bdc7fed1b3589 region proms offs 0 ) rom ( name mp1-6.4c size 256 crc 50765082 sha1
chip ( type cpu name M6809 clock 1536000 )
chip ( type cpu name M6809 clock 1536000 )
chip ( type audio name Namco_15XX )
video ( screen raster orientation vertical x 224 y 288 aspectx 3 aspecty 4 freq 60.606060 ) sound ( channels 1 )
input ( players 2 control joy8way buttons 1 coins 2 )
dipswitch ( name "Cabinet" entry "Upright" default "Upright" entry "Cocktail" ) )

I will have a variable containing the text string that matches the second line, "name mappy".
I would then like to find the line that begins with "video" and retrun one of the parameters that follow. It will be the one after the word
"orientation" and it will be either "vertical" or "horizontal". I the want
to set a variable to either "v" or "h" so I can apply my code. It's a pretty
large text file, about 30MB. What is the best way to do this? The other day
I was able to get a number to return that was the character number of the
first string, but I got stuck after that.
Thank you,
John

Nov 20 '05 #3

P: n/a
* "=?Utf-8?B?amNyb3VzZQ==?=" <an*******@discussions.microsoft.com> scripsit:
Here is a sniplet from a text file:

game (
name mappy
description "Mappy (US)"
year 1983
manufacturer "Namco"
history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1. Mappy \n2. Hopping Mappy \n\n0.26 [Aaron Giles, Mirko Buffoni] \n\nBugs: \n- \"000\" is displayed on the highscore. If you get more than 30000 pts, it is displayed normally. This happens whether there are \"hiscore.dat\", hi file and cfg file or not. mappy37b4gre Fujix \n- In Mappy (both versions, mappy and mappyjp), if you insert at
rom ( name mp1-5.5b size 32 crc 56531268 sha1 2e356706c07f43eeb67783fb122bdc7fed1b3589 region proms offs 0 )
rom ( name mp1-6.4c size 256 crc 50765082 sha1
chip ( type cpu name M6809 clock 1536000 )
chip ( type cpu name M6809 clock 1536000 )
chip ( type audio name Namco_15XX )
video ( screen raster orientation vertical x 224 y 288 aspectx 3 aspecty 4 freq 60.606060 )
sound ( channels 1 )
input ( players 2 control joy8way buttons 1 coins 2 )
dipswitch ( name "Cabinet" entry "Upright" default "Upright" entry "Cocktail" )
)

I will have a variable containing the text string that matches the second line, "name mappy".

I would then like to find the line that begins with "video" and retrun
one of the parameters that follow.
You can use 'Strings.Left' to check that.
It will be the one after the word "orientation" and it will be either
"vertical" or "horizontal". I the want to set a variable to either "v"
or "h" so I can apply my code.


If the line starts with "video", you can look for the "(", ")" using
'Strings.InStr', and then split up the remaining part or look for
"vertical" or "horizontal" using 'Strings.InStr' too.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

P: n/a
* "=?Utf-8?B?amNyb3VzZQ==?=" <an*******@discussions.microsoft.com> scripsit:
Here is a sniplet from a text file:

game (
name mappy
description "Mappy (US)"
year 1983
manufacturer "Namco"
history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1. Mappy \n2. Hopping Mappy \n\n0.26 [Aaron Giles, Mirko Buffoni] \n\nBugs: \n- \"000\" is displayed on the highscore. If you get more than 30000 pts, it is displayed normally. This happens whether there are \"hiscore.dat\", hi file and cfg file or not. mappy37b4gre Fujix \n- In Mappy (both versions, mappy and mappyjp), if you insert at
rom ( name mp1-5.5b size 32 crc 56531268 sha1 2e356706c07f43eeb67783fb122bdc7fed1b3589 region proms offs 0 )
rom ( name mp1-6.4c size 256 crc 50765082 sha1
chip ( type cpu name M6809 clock 1536000 )
chip ( type cpu name M6809 clock 1536000 )
chip ( type audio name Namco_15XX )
video ( screen raster orientation vertical x 224 y 288 aspectx 3 aspecty 4 freq 60.606060 )
sound ( channels 1 )
input ( players 2 control joy8way buttons 1 coins 2 )
dipswitch ( name "Cabinet" entry "Upright" default "Upright" entry "Cocktail" )
)

I will have a variable containing the text string that matches the second line, "name mappy".

I would then like to find the line that begins with "video" and retrun
one of the parameters that follow.
You can use 'Strings.Left' to check that.
It will be the one after the word "orientation" and it will be either
"vertical" or "horizontal". I the want to set a variable to either "v"
or "h" so I can apply my code.


If the line starts with "video", you can look for the "(", ")" using
'Strings.InStr', and then split up the remaining part or look for
"vertical" or "horizontal" using 'Strings.InStr' too.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

P: n/a
How about an example based on my first post

Thank you
John
Nov 20 '05 #6

P: n/a
Jcrouse,
I would do as Armin suggested in your other thread. Create a parser
(Serializer) to parse the file format into an object model. Then check the
object model.

Instead of an object model, I would also consider creating an XPath
navigator for your file format, then extract the data using XPath
statements.

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

Creating an XPath navigator also enables you to convert the file format into
XML, which may or may not be more manageable (editable) then the current
format.

You might be able to use Regular Expressions to help create a parser, or at
least to extract a specific line of the description.

A tutorial & reference on using regular expressions:
http://www.regular-expressions.info/

The MSDN's documentation on regular expressions:
http://msdn.microsoft.com/library/de...geElements.asp

Hope this helps
Jay
"jcrouse" <an*******@discussions.microsoft.com> wrote in message
news:16**********************************@microsof t.com...
Here is a sniplet from a text file:

game (
name mappy
description "Mappy (US)"
year 1983
manufacturer "Namco"
history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1.
Mappy \n2. Hopping Mappy \n\n0.26 [Aaron Giles, Mirko Buffoni] \n\nBugs: \n-
\"000\" is displayed on the highscore. If you get more than 30000 pts, it is
displayed normally. This happens whether there are \"hiscore.dat\", hi file
and cfg file or not. mappy37b4gre Fujix \n- In Mappy (both versions, mappy
and mappyjp), if you insert at rom ( name mp1-5.5b size 32 crc 56531268 sha1 2e356706c07f43eeb67783fb122bdc7fed1b3589 region proms offs 0 ) rom ( name mp1-6.4c size 256 crc 50765082 sha1
chip ( type cpu name M6809 clock 1536000 )
chip ( type cpu name M6809 clock 1536000 )
chip ( type audio name Namco_15XX )
video ( screen raster orientation vertical x 224 y 288 aspectx 3 aspecty 4 freq 60.606060 ) sound ( channels 1 )
input ( players 2 control joy8way buttons 1 coins 2 )
dipswitch ( name "Cabinet" entry "Upright" default "Upright" entry "Cocktail" ) )

I will have a variable containing the text string that matches the second line, "name mappy".
I would then like to find the line that begins with "video" and retrun one of the parameters that follow. It will be the one after the word
"orientation" and it will be either "vertical" or "horizontal". I the want
to set a variable to either "v" or "h" so I can apply my code. It's a pretty
large text file, about 30MB. What is the best way to do this? The other day
I was able to get a number to return that was the character number of the
first string, but I got stuck after that.
Thank you,
John

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.