473,467 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Substring Text File

13 New Member
Hi Programmers

Look at the text files below -

.................................................. .................................................. ............
18-JUL-2008 11:10 JOKOTO UNIVERSITY Page : 1

Dept : 6601 - BUSINESS INFORMATICS
Subject : IDC30AE - INDUSTRY EXPOSURE IIIA

Class Group : A
Responsible Lecturer(s): 5000282 MR H MATOLO (Primary)
Student
Number and Name
800128241 MOLOOI,DI
804282322 KOPEN,BT
.................................................. .................................................. ...

My Question :


This is the format of text file that i am working with , my task is to start by substring from Dept but i failed to do that , what i can do is to substring from begin of files, can u pls guysb give me idea?
Oct 17 '08 #1
5 2700
JosAH
11,448 Recognized Expert MVP
Hi Programmers

Look at the text files below -

.................................................. .................................................. ............
18-JUL-2008 11:10 JOKOTO UNIVERSITY Page : 1

Dept : 6601 - BUSINESS INFORMATICS
Subject : IDC30AE - INDUSTRY EXPOSURE IIIA

Class Group : A
Responsible Lecturer(s): 5000282 MR H MATOLO (Primary)
Student
Number and Name
800128241 MOLOOI,DI
804282322 KOPEN,BT
.................................................. .................................................. ...

My Question :


This is the format of text file that i am working with , my task is to start by substring from Dept but i failed to do that , what i can do is to substring from begin of files, can u pls guysb give me idea?
Simply read the first two lines and discard them. The third line you read will be the
line you want to process.

kind regards,

Jos
Oct 17 '08 #2
Walter Thizo
13 New Member
Simply read the first two lines and discard them. The third line you read will be the
line you want to process.

kind regards,

Jos

I appreciate your respond but look what i did (Code below)-


//loop through the file
for (int x=0 ; x < 21 ; x++)
{


//read the first line and delete
Space = OneFileLine.Pos("-");
IDStud = OneFileLine.SubString(1,Space-1 ) ;
OneFileLine = OneFileLine.Delete(1,Space );

Comma = OneFileLine.Pos(":");
StudSurname = OneFileLine.SubString(1,Comma-1 ) ;
OneFileLine = OneFileLine.Delete(1,Comma );


but my problem is that line is too long ,maybe can u give me shortest method of reading line and discard pls ?
Oct 17 '08 #3
JosAH
11,448 Recognized Expert MVP
What language is that? Is it C#? This is a C and C++ forum; nevertheless, if you're
talking C++ have a look at the istream.getline() function, if you're talking C have
a look at the fgets() function.

kind regards,

Jos
Oct 17 '08 #4
Walter Thizo
13 New Member
What language is that? Is it C#? This is a C and C++ forum; nevertheless, if you're
talking C++ have a look at the istream.getline() function, if you're talking C have
a look at the fgets() function.

kind regards,

Jos

Jos , it is C++ and all i want is a logic of how can i use getline function to solve my problem because I did use getline fuction to read all records inside the text file .So pls can u give me the logic

Kind Regards
Oct 17 '08 #5
JosAH
11,448 Recognized Expert MVP
Jos , it is C++ and all i want is a logic of how can i use getline function to solve my problem because I did use getline fuction to read all records inside the text file .So pls can u give me the logic

Kind Regards
I already gave you the best options in reply #4. Just read and discard the first
two lines before you start your loop.

kind regards,

Jos
Oct 17 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dave | last post by:
Hi all, Am I blind, or what? I can't find any quick way to do the following in Python: substring(beginIndex, endIndex) witch returns the substring between beginIndex and endIndex. Like:...
7
by: junky_fellow | last post by:
Can anyone suggest some efficient way to search a substring in a text file. For eg. suppose i want to search the pattern "abc" in a text file, then which algorithm should i use. I just want some...
6
by: Tarun | last post by:
Hi All, I need to find a particular substring in a binary string(some text appended & prepended to binary data). I cant use strstr since it terminates on receiving '\0'which can be there in...
3
by: Tim Soliday | last post by:
I have been looking at regular expressions lately, and I'm hoping that maybe someone could help me? I am trying to find the position of a substring, and then returning the substring including...
3
by: Bruce D | last post by:
I've found a problem in my program. I'm reading a file (fixed length) and I'm using a structure to return the values...all ok. But the problem arises when the length of the line I'm reading isn't...
1
by: sandhya2006 | last post by:
Dear Friends, I have two textfiles , Ex:first text is like this AAA A B C D .................. .................... ZZZ CC GG Second text file is A a B b
1
chunk1978
by: chunk1978 | last post by:
hello... i'm trying to copy the file name of a string into a text box after a user selects a file from their computer. that part works fine. however, Macs and PCs write file paths differently: ...
4
by: SM | last post by:
Hello, I have a simple question, but can't find the answer. I have a string that contains a path to a file I want to add another string to the end of that string So, if i have : path =...
11
by: dyc | last post by:
how do i make use of substring method in order to extract the specified data from a a long string? I also need to do some checking b4 extracting the data, for instance: it only will extract the...
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...
1
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
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...
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.