String Search in a LARGE text file

G

Guest

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
 
C

Cor Ligthert

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.
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?amNyb3VzZQ==?= said:
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.
 
J

Jay B. Harlow [MVP - Outlook]

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/issues/04/05/XMLFiles/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/d...l/cpconRegularExpressionsLanguageElements.asp

Hope this helps
Jay


jcrouse said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top