How to process huge text files that contain EOF / Ctrl-Z characters using Python on Windows?

It’s easy to use Python to delete the DOS EOF chars; for example, def delete_eof(fin, fout): BUFSIZE = 2**15 EOFCHAR = chr(26) data = fin.read(BUFSIZE) while data: fout.write(data.translate(None, EOFCHAR)) data = fin.read(BUFSIZE) import sys ipath = sys.argv[1] opath = ipath + “.new” with open(ipath, “rb”) as fin, open(opath, “wb”) as fout: delete_eof(fin, fout) That takes … Read more

How do you read scanf until EOF in C?

Try: while(scanf(“%15s”, words) != EOF) You need to compare scanf output with EOF Since you are specifying a width of 15 in the format string, you’ll read at most 15 char. So the words char array should be of size 16 ( 15 +1 for null char). So declare it as: char words[16];

ifstream not reading EOF character

First thing is first, you shouldn’t check like that. eof() doesn’t return true until after a failed read. But you can do better (and easier)! check the stream state with the implicit conversion to void* which can be used in a bool context. Since most of the read operations on streams return a reference to … Read more

Having troubles with EOF on Windows 7

Assuming you’re on Windows, the situation is that you basically have to do the ctrl+Z at the beginning of a line — i.e., you have to have hit enter, then do the ctrl+Z, then (depending on how the input is being read) possibly enter again. You can also use F6 to signal the end of … Read more

End of File in C++

This is the wrong way to read a file: while (!fin.eof( )) { // readLine; // Do Stuff } The standard pattern is: while(getlineOrValues) { // Do Stuff } So looking at your code quickly I think it would be asier to write it as: while(fin>>c_tmp>>gamma_tmp) { // loop only eneterd if both c_tmp AND … Read more