eof

How to check for EOF in Python?

How do I check for EOF in Python? I found a bug in my code where the last block of text after the separator isn't added to the return list. Or maybe there's a better way of expressing this function? Here's my code: def get_text_blocks(filename): text_blocks = [] text_block = StringIO.StringIO() with open(filename, 'r') as f...

How do I send an EOF for a Java InputStream element?

so i have the following code opening an input stream and collecting the information successfully: httpInput = httpConnection.openInputStream(); sb= new StringBuffer(); while (ch != -1) { ch = httpInput.read(); sb.append(...

How can I check for eof in Perl?

So I have a bit of problem figuring what Perl does in the following case: while(1){ $inputLine=<STDIN> #parse $inputLine below #BUT FIRST, I need to check if $inputLine = EOF } before I get the obvious answer of using while(<>){}, let me say that there is a very strong reason that I have to do the above (basically setting up an alar...

How to Handle EOFError for raw_input() in python in Mac OS X

My python program has two calls to raw_input() The first raw_input() is to take multiline input from the user. The user can issue Ctrl+D (Ctrl+Z in windows) for the end of input. Second raw_input() should take another input from user with (y/n) type prompt. Unfortunately (in Mac OS X only?), second raw_input() raises EOFError when th...

javascript vbcript seek eof

Hello, I am writing a destop script on windows 2003 and I need to open a file and seek to the end of it and read the last line. I looked for a "seek" but couldn't find. I saw the openTextFile for option but didn't have. I implement it by openning the file with the red flag and then reading line after line. With big file it takes a ti...

Why is it recommended to have empty line in the end of file?

Some code style tools recommend this and I remember seeing some unix command line tools warning about missing empty line. What is the reasoning for having an extra empty line? ...

EOF character in XCode (ctrl + d)

I'm doing a hw assignment and my professor uses this code to test our program: int main() { const int SZ1 = 10; const int SZ2 = 7; const int SZ3 = 5; float array1[SZ1]; float array2[SZ2]; float array3[SZ3]; DisplayValues(SortValues(GetValues(array1, SZ1), SZ1), SZ1); DisplayValues(SortValues(GetValues(array2, SZ...

Handling SIGCHLD will return EOF to the father, why?

I have a small shell that creates children (with fork()) and make them execute some commands with execvp. It support also the & option so the father can run other commands in the meanwhile. When a child die i want to write that on the console and also the child pid, so i defined a sighandler for SIGCHLD: void backdeadchild(int sig) { i...

C++ EOF Getline Error

I was using the form used in one of the related questions. Only problem is that i keep getting right at the end of the file. The file is an fstream and the str is a string. Unhandled exception Microsoft C++ exception: std::ios_base::failure while (getline(file, str)) { } if (cin.bad()) { // IO error } else if (!cin.eof()) ...

Checking for an empty file in C++

Is there an easy way to check if a file is empty. Like if you are passing a file to a function and you realize it's empty, then you close it right away? Thanks. Edit, I tried using the fseek method, but I get an error saying 'cannot convert ifstream to FILE *'. My function's parameter is myFunction(ifstream &inFile) ...

Does EOF actually exist?

Hi, When I use file functions in PHP, I check for EOF. I wonder if EOF actually exist in a file. When I create an empty text file, it displays 0KB. How does EOF exist in a file with 0KB? ...

EOF of excel in vb6

how do i write the code in vb6 in finding the EOF of excel file can anyone help me? i try to code this and it works.. ---> Dim excelApp as Excel.Application Dim excelWB as Excel.Workbook Set excelApp = New Excel.Application Set excelWB = excelApp.Workbooks.Open("D:\Book1.xls") Dim xlsRow as Long Dim EOF as Boolean xlsRow = 1 D...

How to send EOF to stdin in paramiko?

I would like to execute some program through ssh and redirect its input from a file. The behaviour of the following code: channel.exec_command('cat') with open('mumu', 'r') as f: text = f.read() nbytes = 0 while nbytes < len(text): sent = channel.send(text[nbytes:]) if sent == 0: break nby...

I need to know inside of "while(fscanf != EOF){blah}" if the next fscanf is going to return EOF-- because I need to keep executing portions of the {blah} code after fscanf hits EOF. ?

I've got some code executing in a while(fscanf != EOF) loop. However, even when fscanf has finished executing, I need to keep running that code until some conditions are met. I mean I guess I could copy/paste the code to outside the while(fscanf) loop, and only use global variables, but that seems messy. Surely someone has encountered so...

Scan file contents into an array of a structure.

Hello, I have a structure in my program that contains a particular array. I want to scan a random file with numbers and put the contents into that array. This is my code : ( NOTE : This is a sample from a bigger program, so I need the structure and arrays as declared ) The contents of the file are basically : 5 4 3 2 5 3 4 2 #include...

Can we write an EOF character ourselves?

Most of the languages like C++ when writing into a file, put an EOF character even if we miss to write statements like : filestream.close However is there any way, we can put the EOF character according to our requirement, in C++, for an instance. Or any other method we may use apart from using the functions provided in C++. If you ne...

Can read(2) return zero when not at EOF?

According to the man page for read(2), it only returns zero when EOF is reached. However, It appears this is incorrect and that it may sometimes return zero, perhaps because the file is not ready to be read yet? Should I call select() to see if it is ready before reading a file from disk? Note that nBytes is: 1,445,888 Some sample co...

Equivalent of RecordSet.MoveNext while Not EOF in ASP.NET

Hello, I'm using a DataReader to display informations stored in a table. I created Two button to go to next record and to go back. In VB6 I used this code : While Not Recordset1.EOF Recordset1.MoveNext End While In ASP.NET I didn't find a way to do like it, because DataReader hasn't the EOF property. EDIT : While Not Recordset1.B...

C++ iostreams question

Hello! I have the following question on boost::iostreams. If someone is familiar with writing filters, I would actually appreciate your advices / help. I am writing a pair of multichar filters, that work with boost::iostream::filtering_stream as data compressor and decompressor. I started from writing a compressor, picked up some algor...

Problem with POSTing XML data to an API using Java

I'm having problem with sending XML-data using HTTP POST to an API. If I send well formatted XML, I get an error message: Server Exception: Cannot access a closed Stream If the XML isn't well formatted, I get HTTP 500. And if I just send an empty string instead of a string with XML, I get back an error message: EMPTY REQUEST. I ...