binaryfiles

Python - converting wide-char strings from a binary file to Python unicode strings...

It's been a long day and I'm a bit stumped. I'm reading a binary file that contains lots of wide-char strings and I want to dump these out as Python unicode strings. (To unpack the non-string data I'm using the struct module, but I don't how to do the same with the strings.) For example, reading the word "Series": myfile = open("test...

using bash: write bit representation of integer to file

Hullo First, I want to use bash for this and the script should run on as many systems as possible (I don't know if the target system will have python or whatever installed). Here's the problem: I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the o...

Problem with reading and writing to binary file in C++

I need to make a file that contains "name" which is a string -array of char- and "data" which is array of bytes -array of char in C++- but the first problem I faced is how to separate the "name" from the "data"? newline character could work in this case (assuming that I don't have "\n" in the name) but I could have special characters in ...

unformatted input to a std::string instead of c-string from binary file.

ok i have this program working using c-strings. I am wondering if it is possible to read in blocks of unformatted text to a std::string? I toyed arround with if >> but this reads in line by line. I've been breaking my code and banging my head against the wall trying to use std::string, so I thought it was time to enlist the experts. ...

Reading a binary file in Python into a struct

How do I go about opening a binary data file in Python and reading back the values one long at a time, into a struct. I have something like this at the moment but I think this will keep overwriting idList, I want to append to it, so I end up with a tuple of all the long values in the file - file = open(filename, "rb") try: ...

How to read data from a Nicolet FTIR spectral file with extension of *.spa

Is the *.spa binary file format trade secret? But Perkin Elmer released *.sp format to public; how to read? ...

Map element position in data file to class property

I need to read/write files, following a format provided by a third party specification. The specification itself is pretty simple: it says the position and the size of the data that will be saved in the file. For example: Position Size Description -------------------------------------------------- 0001 10 ...

Tell git not to merge binary files but to choose

When the binary files, swfs, jars and flvs are changed locally, and I try to pull in changes, git tries to merge them and reports conflict. And then, I branch to a temporary branch, and commit the local changed binary files, and merge them back after the pull with recursive theirs strategy. -- Too much work. Is there a way to tell git,...

Creating a binary file from an IntelHex in C#

I'm trying to create a binary file from a intelHex file. Iside the intelHex file I have data and address to which I should write the data inside the binary file. IntelHex file looks like that :10010000214601360121470136007EFE09D2190140 :100110002146017EB7C20001FF5F16002148011988 :10012000194E79234623965778239EDA3F01B2CAA7 :100130003F015...

binary file to string

i'm trying to read a binary file (for example an executable) into a string, then write it back FileStream fs = new FileStream("C:\\tvin.exe", FileMode.Open); BinaryReader br = new BinaryReader(fs); byte[] bin = br.ReadBytes(Convert.ToInt32(fs.Length)); System.Text.Encoding enc = System.Text.Encoding.ASCII; string myString = enc.GetStri...

Can GIT, Mercurial, SVN, or other version control tools work well when project tree has binary files?

Sometimes our project tree can have binary files, such as jpg, png, doc, xls, or pdf. Can GIT, Mercurial, SVN, or other tools do a good job when only part of a binary file is changed? For example, if the spec is written in .doc and it is part of the repository, then if it is 4MB, and edited 100 times but just for 1 or 2 lines, and chec...

Using boost::iostreams to parse a binary file byte by byte

So I would like to parse a binary file and extract some data from it. The problem I am facing with this is that I need to convert a stream of chars to a stream of unsigned chars. Reading the boost documentation, it seems that boost::iostreams::code_converter should be the solution for this, so I tried this: typedef unsigned char uint8_t...

store/load numpy array from binary files

Dear all, I would like to store and load numpy arrays from binary files. For that purposes, I created two small functions. Each binary file should contain the dimensionality of the given matrix. def saveArrayToFile(data, fileName): with open(fileName, 'w') as file: a = array.array('f') nSamples, ndim = data.shape ...

Binary Files in C#

hi i am writing a project in C# i wanna save a class in binary file and then read that file it in C i wanna know how can i do it without serialize and deserialize please help me ...

file reading: feof() for binary files

Hey; I am reading a binary file. and when it reaches the end. it seems it is terminated by feof() function. is it because there is no EOF character for binary files? if so how can i solve it. currently my code is using a while loop while (!feof(f)) when it reaches the end of file at position 5526900. it doesn't stop. it just keeps...

casting from binary to multi-dimensional array on heap

i'm currently using binary files for quick access to custom objects stored in multidimensional arrays which are saved to file as object arrays. so far, reading from file hasn't been too much of a problem since i've been reading the array into an identical object array on the stack. it looks something like this: Foo foo[5][10]; ifstream ...

Changing hash of a files

Hi guys I have a folder full of binary files and I want to make a change to these files so that the hash of these files will change. I want to do this is a fashion that doesn't pertinently corrupt the files. Meaning that the change should still allow the file to operate normally or that I should be able to undo the change at any point ...

Binary file lost using svn merge

I have two branch (let say branch A and branch B)in my svn repository I'm done with one of them, branch B I want to get changes of the other branch ,branch A. On both branch i have binary files,in a separated folder. When i try to get the new binary files of branch A, i get nothing, just tree conflict. I use subclipse, merge a range of ...

Is there a tried and true way of accessing specific areas of a very large (>1GB) binary file very fast in .Net

Using a very large raw binary data file, I will be creating a large binary file (greater than 1 GB, usually greater than 4 GB) that contains sensor data from an arbituary number of sensors (1 to 64). The new processed file will be used by user in a GUI where they will be jumping around the file looking at different time periods or other ...

Read binary file in C# or C++

I have to read a binary file data into a C# winform application. The binary reading is frequent, i.e. many form reads different section of data. I can create a C++ dll to read the binary file and use it in C# application. or I can have the reading logic in C#. The main issue if performance. If I write it into C# will it give me ...