473,655 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

find EOF in text file

13 New Member
hi guys

i need help, my situation: i need to find EOF in my text file and when it is not present it will display a prompt.
Jul 17 '07 #1
5 3830
dafodil
392 Contributor
Heres how you can detect the end of file from a file....
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $file = fopen("test.txt","r");
  3.  
  4. while(!feof($file))
  5.   {
  6.   //your statements here....
  7.   }
  8. echo "end of file!";
  9. fclose($file);
  10. ?>
  11.  
Jul 17 '07 #2
kid
13 New Member
sir how can i check the file if it has a EOF? that is my major problem.

sample data A:

a,b,c,d

Sample data B:

a,b,c,d
EOF


if sample data A has no EOF the program must stop. need help pls.
Jul 17 '07 #3
dafodil
392 Contributor
sir how can i check the file if it has a EOF? that is my major problem.

sample data A:

a,b,c,d

Sample data B:

a,b,c,d
EOF


if sample data A has no EOF the program must stop. need help pls.
You mean a text EOF, I thought you are detecting the last part if it is already End OF File....
Jul 17 '07 #4
dafodil
392 Contributor
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $t="";
  3. $file = fopen("test.txt","r");
  4.  
  5. while(!feof($file))
  6.   {
  7. $t=fgets($file). "<br />";
  8.  
  9. if($t=="EOF"){
  10. echo "EOF";
  11. }
  12.  
  13.   }
  14. fclose($file);
  15. ?>
  16.  
As you can see the code above will read the file line by line...
You should write the text EOF at the end of the file in one line....
If it detects it, it displays EOF....
Jul 17 '07 #5
kid
13 New Member
thank you so much!!! that works!
Jul 17 '07 #6

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

Similar topics

1
3719
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
5
11025
by: Tim Eliot | last post by:
Just wondering if anyone has hit the following issue and how you might have sorted it out. I am using the command: DoCmd.TransferText acExportMerge, , stDataSource, stFileName, True after setting stDataSource and stFileName to the desired values. Most of the time it works, but occasionally, typically as code changes are being made to the module, the following message appears:
7
2853
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
2
8072
by: Paul | last post by:
Can anyone show me a good refined way to find and replace a portion of text held in a text file held on a web server? Thanks in Advance
3
16914
by: TOXiC | last post by:
Hi everyone, First I say that I serched and tryed everything but I cannot figure out how I can do it. I want to open a a file (not necessary a txt) and find and replace a string. I can do it with: import fileinput, string, sys fileQuery = "Text.txt" sourceText = '''SOURCE'''
7
5096
by: mark | last post by:
Hi All, Apologies for the newbie question but I've searched and tried all sorts for a few days and I'm pulling my hair out ; Please feel free to teach me to suck eggs because it's all new to me :) Thanks in advance, Mark.
3
2782
by: =?Utf-8?B?R3JlZyBN?= | last post by:
Hello, I'm running an asp.net, intranet web application using .net framework 1.1 on IIS5.1 / 6.0. Through the web application, I would like to press a button on the web page, have another window (not web-based or part of current application) brought to the front and focused (findwindow api) and have the button scrape the contents of the focused window so the contents can be parsed and entered into the web application. Ideally, I would...
7
38220
by: kushaldutt | last post by:
Hi all, I am having trouble finding and replacing text in a xml file. My issue is I have to find a text in a xml file and change it to some other text. But the text in some element tag for ex: 'Name' should not be changed. So, for example the xml is as shown below and I had to find and replace the text 'Hello' with 'Hi' but with out changing the Name tag. <Book> <Name> Hello Book</Name> <Descr>Hello there </Descr> <Price>15</Price>
2
12613
by: Perl Beginner | last post by:
Hi, Is there a way to find a line in a text file that starts with a forward slash? This is how i find a line in text file that starts with a word and then print that line to another text file: open( FILE, "<$file" ); open( COPIED_FILE, ">$copiedfile" ); while( <FILE> ) { $templine = $_; if ($templine =~ m/DELTA\//)
2
6650
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI Week5MortgageLogic allint = logic.allInterest(amount, term, rate); Week5MortgageGUI.java:152:cannot find symbol symbol: method allInterest(double,double,double) Location: class Week5MortgageGUI
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8710
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
8497
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
8598
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...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
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();...
1
2721
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
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.