473,396 Members | 1,599 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.

String Search in a LARGE text file

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
6 2214
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
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
* "=?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
* "=?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
How about an example based on my first post

Thank you
John
Nov 20 '05 #6
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Anand Pillai | last post by:
To search a word in a group of words, say a paragraph or a web page, would a string search or a regexp search be faster? The string search would of course be, if str.find(substr) != -1:...
5
by: BILL | last post by:
Hi Everyone, I've been looking through these .NET groups and can't find the exact answer I want, so I'm asking. Can someone let me know the best way (you feel) to search a C# string for an...
60
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't...
5
by: Jim | last post by:
Hello, I am working on a small windows application for a client, and as one of the functions they want a search that will let them enter a search string, then search a directory for all flies...
6
by: mandibdc | last post by:
I need to extract some elements from a very large XML file. Because of the size, I'd like to work with it on my Linux machine as a text file. Basically, I am going to have a list of specific...
33
by: Bertram Trabant | last post by:
Hello, Im working on a little LAN game in the style of old text-only MUD's and would need to find a way to search for a string in a text file (for example for usernames). I know it works in the way...
5
by: beersa | last post by:
Hi All, I have to query the database with the string from text file. Here are the details: OS: WinXP Home Pro DB: Oracle 9.x The table in DB has 20,000 rows. The text file has 15,000...
13
by: liujiaping | last post by:
Hi, all. I have a dictionary-like file which has the following format: first 4 column 7 is 9 a 23 word 134 .... Every line has two columns....
9
by: Clinto | last post by:
Hi, I am trying to find the fastest way to search a txt file for a particular string and return the line that contains the string. I have so for just used the most basic method. Initialized a...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.