Questions tagged [stringio]

Use for questions concerning the Python 2 module StringIO or the class StringIO it contains. In Python 3, this refers to the class StringIO of the io module.

Python class StringIO allows to read and write a string buffer (also known as memory files).

355 questions
0
votes
1 answer

StringIO to capture log, but it's not written

I want to capture log entries into a string, to display in a wx dialog. I just can't get the StringIO to be filled by the log entries... what wrong here? # prepare logging log = StringIO.StringIO('Report') logger = logging.getLogger…
virtualnobi
  • 1,140
  • 2
  • 11
  • 35
0
votes
2 answers

file like io data structure in python that does not use files at all

I am looking for a file like io data structure in python that does not use files at all. So just a memory file. I tried cStringIO, which is quite what I was looking for with the limitation that it is not usable via select. That is sound, but is…
mkind
  • 2,015
  • 2
  • 20
  • 25
0
votes
1 answer

Best way to mock out StringIO input for Ruby unit test?

Is there a better way to mock out StringIO input? I'm specifically looking for a way to avoid having to call the .rewind method. I tried using the block form of StringIO.open but it zeros out the internal string when returning it. test_input =…
Jazzepi
  • 5,259
  • 11
  • 55
  • 81
0
votes
2 answers

Appending files to each other without adding the title row each time

Bonjour Stack0verflow I am trying to get this code to write the data to stored_output without line 1 (title line) What I have tried: with open(filenamex, 'rb') as currentx: current_data = currentx.read() ## because of my filesize I dont want…
AEA
  • 213
  • 2
  • 12
  • 34
0
votes
3 answers

Not able to inline replace using re.sub and io.StringIO in Python

I have written this method in order to replace text in line. It prints the correct text as I want it to be replaced but it is not updating those changes in the file. I am quite new to Python, Could you please help me where I am making a mistake? def…
Zeeshan
  • 1,200
  • 12
  • 17
0
votes
1 answer

The specified procedure could not be found. - Init_StringIO

Can someone tekl me what's going on here? This used to work for me but now I'm getting this error in both ruby 1.8.7 and ruby 1.9.3 require 'StringIO' #LoadError: 127: The specified procedure could not be found. - Init_StringIO
pguardiario
  • 53,827
  • 19
  • 119
  • 159
0
votes
1 answer

python POST a StringIO using poster

Here is the situation: I use PIL to process an image, then I save it to a StringIO object. Now, I want to POST the StringIO object through poster. But, I can't get the image in the request.FILES dict. I have googled for a few hours, I found this…
Jinvan
  • 33
  • 1
  • 6
0
votes
3 answers

python: csv to json conversion when csv contains unicode

I'm trying to use the following code (within web2py) to read a csv file and convert it into a json object: import csv import json originalfilename, file_stream = db.tablename.file.retrieve(info.file) file_contents = …
Lamps1829
  • 2,231
  • 3
  • 24
  • 32
0
votes
1 answer

python: memory shared between StringIO?

Is the memory shared between the StringIO if I do that? I have the feeling it is because the memory of the python process did not increase on line 6. In [1]: from StringIO import StringIO In [2]: s = StringIO() In [3]: s.write('abcd'*10000000) #…
Michael
  • 8,357
  • 20
  • 58
  • 86
0
votes
1 answer

running python StringIO files

I want to run a memfile done with StringIO. Is there any possibility for doing it? something like this: import StringIO memfile = StringIO.StringIO() memfile.write("print 'hello world'") #with diskfiles I would do: #os.system('python memfile')…
0
votes
1 answer

Python Curl writefunction not working onsecond call

I've written a simple script in Python. It parses the hyperlinks from a webpage, and afterwards these links are retrieved to parse some information. I have similar scripts running and re-using the writefunction without any problems, for some reason…
0
votes
1 answer

Create image object from image stdout output of external program in Python

I have a program that generates pictures and either saves them to a file or prints out the raw image data in standard output. I am using Python subprocess module to call the external program, catch its stdout data and create a Python image object…
pkout
  • 6,430
  • 2
  • 45
  • 55
0
votes
1 answer

To check an instance is 'StringIO'

>>> import cStringIO >>> a = cStringIO.StringIO() >>> type(a) >>> isinstance(a, cStringIO.StringO) Traceback (most recent call last): File "", line 1, in isinstance(a,…
thkang
  • 11,215
  • 14
  • 67
  • 83
0
votes
1 answer

Load a list into memory with python? or is it already in the memory?

I'm writing a program that opens a database file saved with pickle. but if i want to load the list from the file into the memory with StringIO/cStringIO it says: Opening database... Loading database into memory... Traceback (most recent call…
Yannick
  • 372
  • 1
  • 9
0
votes
1 answer

different between stringio.write and += on byte stream

I met a strange problem recently, hope someone here can help me out. I'm using Python2.7 in Ubuntu12.04, both python and OS are 64-bits. In my code, I need to keep appending incoming data stream to a byte array, I use self.data += incomingdata to…
ypeng
  • 11
  • 2
1 2 3
23
24