• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Text analysis program? (Beginner challenge).

MagicSam

Junior Member
Hey guys,

First off, I have absolutely no programming experience or background whatsoever.

I set myself a goal recently of being to program a challenge an IT teacher set a friend of mine a few months ago, and I would really appreciate it if some of those with the necessary skills and experience could provide me with a "path" I can follow to be able to program it.

I have in my possession a large text file which I wish to analyse.

The file is in the following format

xxxxxxxxxxx 1240 xxxxxxxx
xxxxxxxxxxx 1345 xxxxxxxx
xxxxxxxxxxx 1658 xxxxxxxx

Essentially, I want to isolate the numbers in each line, and track them, triggering different actions when a certain number is hit. For example, if it hits 1240, the program would do a track it, or something of that nature, and when it reaches another specified number, say, 4356 it stops the pair, and then logs that one complete pair has been recorded.

So, my question to you, is where do I start to be able to do this?

I understand that this may be far more complex than I think it to be, but I aim to use this to learn some programming skills over the mid-term future, and a platform to expand my knowledge.

Thanks for your time,
MagicSam
 
1) figure out how to open data file
2) read file
3) parse the line read in
4) analyze the parsed result
5) process based on #4
6) go to #2 or #3 depending on how you read file
 
Those x-characters you typed - are they really present in file strings or there is something else?
 
Where you want to go may depend on how complicated the actions are for each number. If they're very complicated, you may want to look at Yacc or its relatives.

This is one of those times I wish I'd taken that compiler construction class in college.
 
There are two types of text datafiles. Fixed-width and delimited. Your file could be either space-delimted, or fixed-width. That is the first thing you have to figure out.
 
It sounds like something that'd be pretty easy to do with Perl and regular expressions...

I feel kind of dirty suggesting Perl to anyone though so I'm sure any language with regex support could do this pretty easily.
 
Back
Top