Questions tagged [fromfile]
51 questions
10
votes
1 answer
efficient numpy.fromfile on zipped files?
I have some large (even gzipped around 10GB) files, which contain an ASCII header and then in principle numpy.recarrays of about 3MB each, we call them "events". My first approach looked like this:
f = gzip.GzipFile(filename)
f.read(10000) # fixed…

Dominik Neise
- 1,179
- 1
- 10
- 23
8
votes
1 answer
Should I use `readinto` method of python file or not?
I've recently meet the readinto method of file object (in Python 2.7), it is similar to fread in C. It seems to be convenient and powerful in some case. I plan to use it to read several files into one pre-allocated numpy array without data…

Syrtis Major
- 3,791
- 1
- 30
- 40
7
votes
2 answers
python bitarray to and from file
I'm writing a large bitarray to a file using this code:
import bitarray
bits = bitarray.bitarray(bin='0000011111') #just an example
with open('somefile.bin', 'wb') as fh:
bits.tofile(fh)
However, when i attempt to read this data back…

nnachefski
- 1,552
- 2
- 18
- 29
7
votes
4 answers
Loading a picture file Image.FromFile VS FileStream
I must admit that I never understood what are the streams are all about- I always thought it's an internet thing. But now I run into a code that used a stream to load a file localy and I wonder if there is advantage for using a stream over... well…

Asaf
- 3,067
- 11
- 35
- 54
4
votes
2 answers
readinto() replacement?
Copying a File using a straight-forward approach in Python is typically like this:
def copyfileobj(fsrc, fdst, length=16*1024):
"""copy data from file-like object fsrc to file-like object fdst"""
while 1:
buf = fsrc.read(length)
…

Alfe
- 56,346
- 20
- 107
- 159
4
votes
1 answer
How to detect EOF with numpy.fromfile
I am trying to read in a very large (several GB) binary file with numpy.fromfile(). Reading in the entire file at once generates an out of memory error, so I want to create a loop to read and process N chunks of data at a time. Something like the…

Rachel
- 43
- 6
4
votes
1 answer
Extract specific bytes from a binary file in Python
I have very large binary files with x number of int16 data points for y sensors, along with headers with some basic info. The binary file is written as y values for each sample time up to x samples, then another set of readings and so on. If I want…

launchpadmcquack
- 1,021
- 1
- 12
- 19
4
votes
1 answer
Losing alpha channel information opening a BMP file
I have a BMP file which I know is 32bpp and contains alpha information. Whenever I use the System.Drawing.Bitmap class's constructor, or FromFile, it loads it as 32bppRgb instead of 32bppArgb. Is there a way to keep the alpha information?
I know…

nor
- 93
- 6
3
votes
1 answer
Image.FromFile, Not found [But its there]
Its as weird as I have made it out to be. o.0.
I have checked and double checked and dont even see why it doesnt work...
Heres the code in use:
try {
if (!(Directory.Exists(@"C:\SimpleSkype\Identitys")))
…

Sam Clark-Ash
- 175
- 1
- 8
2
votes
1 answer
C# images inside of a ListView
I want to make a ListView that has small images, that was taken from a scanner, inside of the ListView. (I have the scanning script done, and it saves the scanned image under C:/Temp/*.jpg. )
What I'm having trouble with is, I want the scanned…

Throdne
- 619
- 2
- 9
- 27
2
votes
2 answers
Scala : bug with getLines?
I'm facing a problem on a very simple file usage in scala I don't understand if this is from a bug or a misunderstanding what I'm doing...
Even reproducible from a worksheet in scala/eclipse IDE. I'm using IDE4.6.1 and scala 2.12.2
Code is very…

manuthefil
- 33
- 2
2
votes
1 answer
scala BufferedSource Position
I have 2 questions about the Scala class BufferedSource.
How can I query the current reading position ?
I tried it with pos :
object testapp extends App {
val doc = scala.io.Source.fromFile("text.txt")
println(doc.pos)
doc.next()
…

trytillcry
- 35
- 4
2
votes
2 answers
Plotting thousands of files with python
I have in the order or 10^5 binary files which I read one by one in a for loop with numpy's fromfile and plot with pyplot's imshow. Each file takes about a minute to read and plot.
Is there a way to speed things up?
Here is some pseudo code to…

Shahar
- 886
- 1
- 10
- 22
1
vote
4 answers
Image.FromFile will open a path, but not a string containing same path?
// The following line works.
imagebox.Image = Image.FromFile("C:/Users/Admin/Desktop/apps/pic1.png");
// The following line does not work.
imagebox.Image = Image.FromFile(imgPath);
// the test Text Box displays…

zck17
- 19
- 1
- 3
1
vote
1 answer
Can't load image with path from FromFile in UWP
I'm developing an App for Android and UWP. In one screen I need to load an image from the device-filesystem and display it. Strangely it works perfectly on Android, but not on UWP. The Paths seem to be returned correctly by the FilePicker...
My…

DeadPengwin
- 43
- 8