binaryfiles

Edit a Mainframe file in the RecordEditor without a copybook

∥☆過路亽.° 提交于 2019-12-11 16:31:01
问题 How do you Edit a (binary EBCDIC) Mainframe file in the RecordEditor with out a Cobol Copybook. How do you generate Java code to read the file using the RecordEditor. Note: This is an attempt to split a question that is far to broad to give meaningful answer to into a series of simpler Question and Answer's. 回答1: Try and avoid editing a binary file with a Cobol Copybook if at all possible. This should only be attempted as a last resort !!!. Try and get that Cobol copybook (or some field

How to read a class from binary file in c++ [duplicate]

不问归期 提交于 2019-12-11 13:44:00
问题 This question already has answers here : debug read/write string to binary file (3 answers) Closed 3 years ago . I have this code which is supposed to read data to class object from user Write that data to binary file Read data from binary file Display it to user. int main() { Bahd b; //Bahd is a class cin>>b; //overloaded insertion operator ofstream outfile("Data.bin",ios::out|ios::binary); outfile.write(reinterpret_cast<char*>(&b),sizeof(b)); outfile.close(); ifstream infile("Data.bin",ios:

Issues saving double as binary in c++

假装没事ソ 提交于 2019-12-11 12:15:21
问题 In my simulation code for a particle system, I have a class defined for particles, and each particle has a property of pos containing its position, which is a double pos[3]; as there are 3 coordinate components per particle. So with particle object defined by particles = new Particle[npart]; (as we have npart many particles), then e.g. the y-component of the 2nd particle would be accessed with double dummycomp = particles[1].pos[1]; To save the particles to file before using binary I would

How to determine whether a stream is text or binary in Python?

与世无争的帅哥 提交于 2019-12-11 10:04:41
问题 Is there a way to determine (test, check or classify) whether a file (or a bytestream, or other file-like object) is text or binary, similar to the file command's magic in Unix, in a practical majority of cases? Motivation: Although guesswork should be avoided, where Python can determine this, I'd like to utilize the capability. One could cover a useful amount of cases and handle the exceptions. Preference would be given to cross-platform or pure-python methods. One way is python-magic

Incomplete wav file in R, but extra data in file?

∥☆過路亽.° 提交于 2019-12-11 10:02:27
问题 I am trying to open a sound file in R, but the load.wave() function complains that the file is "incomplete". The sound plays well on a number of other audio software (mplayer, Audacity, Praat, etc) and file does not report it to be any different from other WAV files with which there is no problem: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 22050 Hz I know load.wave() internally calls a C function to process the data, but I don't know what that function is, or what it

What is inside SO file of Python library distribution?

做~自己de王妃 提交于 2019-12-11 09:15:52
问题 I got a library, which consists of 3 files FbxCommon.py fbxsip.so fbx.so which are intended to be put in site python directory. Once these files are in place, Python can see fbx package. How it this system works? What is inside SO file? If it is DLL how can it be python version-dependent (it works with python 3.3 but doesn't work with python 3.5) UPDATE Distinguishing code is following from fbx import * lSdkManager = FbxManager.Create() on Python 3.3. it just does nothing, while on Python 3.5

c++ reading and writing objects to binary files

白昼怎懂夜的黑 提交于 2019-12-11 08:12:50
问题 I'm trying to read an array object (Array is a class I've made using read and write functions to read and write from binary files. So far the write functions works but it won't read from the file properly for some reason. This is the write function : void writeToBinFile(const char* path) const { ofstream ofs(path, ios_base::out | ios_base::binary | ios_base::trunc); if (ofs.is_open()) { ofs.write((char*)this, sizeof(Array<T>)); } } This is the read function : void readFromBinFile(const char*

Read/Write Python List from/to Binary file

南笙酒味 提交于 2019-12-11 07:17:32
问题 According to Python Cookbook, below is how to write a list of tuple into binary file: from struct import Struct def write_records(records, format, f): ''' Write a sequence of tuples to a binary file of structures. ''' record_struct = Struct(format) for r in records: f.write(record_struct.pack(*r)) # Example if __name__ == '__main__': records = [ (1, 2.3, 4.5), (6, 7.8, 9.0), (12, 13.4, 56.7) ] with open('data.b', 'wb') as f: write_records(records, '<idd', f) And it works well. For reading

Reading a binary file with memoryview

我们两清 提交于 2019-12-11 05:33:23
问题 I read a large file in the code below which has a special structure - among others two blocks that need be processed at the same time. Instead of seeking back and forth in the file I load these two blocks wrapped in memoryview calls with open(abs_path, 'rb') as bsa_file: # ... # load the file record block to parse later file_records_block = memoryview(bsa_file.read(file_records_block_size)) # load the file names block file_names_block = memoryview(bsa_file.read(total_file_name_length)) #

Read any file as a binary string

╄→гoц情女王★ 提交于 2019-12-11 03:57:48
问题 As the title suggests, is there any way to read a binary representation of a given file (.txt, .docx, .exe, etc...) in Java (or any other language)? In java, I know how to read the content of a file as is, i.e: String line; BufferedReader br = new BufferedReader(new FileReader("myFile.txt")); while ((line = br.readLine()) != null) { System.out.println(line); } But I'm not sure (if it's possible) to read a binary representation of the file itself. 回答1: File file = new File(filePath); byte[]