473,772 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2e356706c07f43e eb67783fb122bdc 7fed1b3589 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 "orientatio n" 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 2246
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 2e356706c07f43e eb67783fb122bdc 7fed1b3589 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
"orientatio n" 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 2e356706c07f43e eb67783fb122bdc 7fed1b3589 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
"orientatio n" 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*******@disc ussions.microso ft.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 2e356706c07f43e eb67783fb122bdc 7fed1b3589 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 "orientatio n" 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*******@disc ussions.microso ft.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 2e356706c07f43e eb67783fb122bdc 7fed1b3589 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 "orientatio n" 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*******@disc ussions.microso ft.com> wrote in message
news:16******** *************** ***********@mic rosoft.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 2e356706c07f43e eb67783fb122bdc 7fed1b3589 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
"orientatio n" 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
39357
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: domything() And the regexp search assuming no case restriction would be,
5
14911
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 occurance of a CASE INSENSITIVE substring, returning the found position. I'm speaking of larger strings to search as well ~50K-500K. Here's what I have so far:
60
49192
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 be indexed/sorted. I don't want to load the entire file into physical memory, memory-mapped files are ok (and preferred). Speed/performance is a requirement -- the target is to locate the string in 10 seconds or less for a 100 MB file. The...
5
2116
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 that contain that search string AND display the lines that contain the search string. They have windows ME, XP and 2000 systems. Does anyone have any ideas as to the most efficient way to do this?
6
2805
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 strings I'm searching for. For each string, I need to search through the XML file, and when I find that string (in the tag <code>), copy the entire <item> XML element that the code appears in, into another text file. The XML document is comprised...
33
2474
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 of looking for the first letter, if matches the second and so on, but don't know how to write it. Any suggestions?
5
2180
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 rows. I wrote a program and read the string from text file and run SELECT query in DB
13
3416
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. The first column is always an English
9
6159
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 variable as IO.streamreader. Read each line and perform an if-then to see if var.contains(mystring) is true or false. if true I get my string if false it reads the next line. This takes for ever. Is there anything I can do to speed this up? Thanks.
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.