-
November 14th, 2016, 08:42 AM
#1
Understanding how to parse a text file.
So a little background. I am a first year uni student, and I am a complete beginner to c sharp. For my first year programming coursework I need to make a word search puzzle. The first part of my specification asks me to parse 3 specific text files. Could someone explain to me how I am meant to go about doing this? The following are the pre-defined text files.
This is what it says in my specification to be specific: -
When the program begins it must first load a word search that has been pre-defined in a text file. 3 puzzle files have been made available as part of the coursework.
The program should be able to load any one of these files.
The file path should be passed to the program via a command line argument.
Refer to the Puzzle File Specification for detailed explanation of the file format.
File01.txt – contains only horizontal words: -
9,5,2
algorithm,0,1,right
virus,5,4,left
File02.txt – contains only horizontal and vertical words: -
9,6,4
algorithm,0,1,right
virus,5,4,left
data,0,0,down
binary,4,5,up
File03.txt – contains horizontal, vertical and diagonal words: -
10,10,8
algorithm,0,1,right
virus,5,4,left
data,0,0,down
binary,4,5,up
loop,8,9,leftup
code,6,9,rightup
compile,8,3,leftdown
file,1,6,rightdown
The above 3 are the text files, what I am going to write below is to understand the text files better.
The first line of the file specifies:
<number of columns>, <number of rows>, <total number of hiddenwords>
Each line that follows specifies the word and its properties: -
<Word>, <Column Co-ordinate of first letter>, <Row Co-ordinate first letter>,<Direction>.
It would be immense help if someone could get me started and explain to me how to parse the above text files. I really hope this thread dosent seem like I am just throwing my homework for someone to do. I genuinely just hoping someone to explain how to do it.
All replies, and help is much appreciated
-
November 14th, 2016, 02:15 PM
#2
Re: Understanding how to parse a text file.
Well, you start by being able to load the text file and be able to read it line by line (after you can do this, you can then focus on how to split up each line). Do you know how to open a file and read it line by line?
-
November 14th, 2016, 04:23 PM
#3
Re: Understanding how to parse a text file.
No. I am completely new to programming. Could you please guide me.
-
November 14th, 2016, 05:10 PM
#4
Re: Understanding how to parse a text file.
Originally Posted by HugeLag
No. I am completely new to programming. Could you please guide me.
I'll do even better, I'll teach you how to find the information yourself.
Search bing or google for "How do I read a line in a text file in C#". In Bing, pick the first item - it shows sample code that will get you going.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|