Questions tagged [cstringio]

A simple fast partial StringIO replacement in Python 2

This module provides a simple useful replacement for the StringIO module that is written in C. It does not provide the full generality of StringIO, but it provides enough for most applications and is especially useful in conjunction with the pickle module.

https://docs.python.org/2/library/stringio.html#module-cStringIO

Note that cStringIO was removed from Python 3 (ref: here).

33 questions
2
votes
1 answer

multi threaded cstringio is 17% slower on ubuntu 14.04

I am running the following program: import cStringIO import time import threading def func(tid): buff = 'a'*4096 i = 0 while (i < 40000000): output = cStringIO.StringIO() output.write(buff) contents =…
2
votes
1 answer

using generators and cStringIO in python to stream strings

I'm trying to read a very large string stream using cStringIO in a python dictionary: def stream_read(self, path): try: # create a string stream from the contents at 'path' # note: the string at self._my_dict[path] is 7MB in…
bacongobbler
  • 867
  • 6
  • 14
2
votes
0 answers

Python using cStringIO and pisa, ordered list (
    ) showing numbers not letters

I'm running a Django website and writing a report that renders a template with view code as an inline PDF file using Pisa and cStringIO. That's all well and good, and working just fine. What I see in HTML from a render_to_response() shows up nicely…
Furbeenator
  • 8,106
  • 4
  • 46
  • 54
1
vote
1 answer

get the size in bytes of a StringIO object

Is it possible to get the size in bytes of a StringIO object? or should i write it to disk every time i want to get its size? I have searched a lot but without success. There .sizeof() but i don't think that is what i want. I am iterating over a…
sdikby
  • 1,383
  • 14
  • 30
1
vote
3 answers

Python using cStringIO with foreach loop

I want to iterate over lines cStringIO object, however it does not seem to work with foreach loop. To be more precise the behavior is as if the collection was empty. What am I doing wrong? example: Python 2.7.12 (default, Aug 29 2016, 16:51:45) [GCC…
jlanik
  • 859
  • 5
  • 12
1
vote
1 answer

ENUM module and cStringIO module in PYVISA

I have some trouble to fix. I am using Python 3.2 with pyvisa for Python 3.2 32bits. When i used: import pyvisa It displayed: ImportError: No module named enum But when I use: import pyqtgraph, pyvisa I get: ImportError: No module named…
1
vote
1 answer

cStringIO.StringO fails to save uploaded file stream when file is smaller than 1kByte

I borrowed this code for saving a file stream to disk, and it works except for when the file is less than 1kb in size. I get this error: in stuff_uploaded: copy(theFile.file.name, './tmp/'+theFile.filename) #saves temporary file to…
Marc Maxmeister
  • 4,191
  • 4
  • 40
  • 54
1
vote
0 answers

Python StringIO memory leak

I have a python program that with time slows to a crawl. I've tested thoroughly, and narrowed it down to a method that downloads an image. The method uses cstringIO and urllib. The problem may also be some sort of infinite download with urllib (the…
William Falcon
  • 9,813
  • 14
  • 67
  • 110
0
votes
0 answers

Capture IPython output in a Python Kernel

I want to capture the output produced by IPython terminal in a Python terminal. As all the testing takes place using a Python Kernel. I know about the IPython magic function. %%capture Is there a way to use these magic functions as context manager…
0
votes
1 answer

StringIO() argument 1 must be string or buffer, not cStringIO.StringIO

I have a function that's reading a content object into a pandas dataframe. import pandas as pd from cStringIO import StringIO, InputType def create_df(content): assert content, "No content was provided, can't create dataframe" if not…
staten12
  • 735
  • 3
  • 9
  • 20
0
votes
1 answer

Cannot Iterate over cStringIO

In a script, I'm writing lines to a file, but some of the lines may be duplicates. So I've created a temporary cStringIO file-like object, which I call my "intermediate file". I write the lines to the intermediate file first, remove duplicates, then…
Alureon
  • 179
  • 1
  • 3
  • 14
0
votes
1 answer

Matplotlib savefig to cStreamIO then load the data into another Matplotlib plot/fig Python 2.7

Attempting to use matplotlib to write out to an iostream then display that data in another matplotlib plot (started by following: Write Matplotlib savefig to html). For efficiency purposes, I want to avoid writing the image to disk. Here's the…
0
votes
1 answer

How do you create an in-memory TSV file with null values, using cStringIO?

I know that I can make a simple in-memory CSV file like this: from cStringIO import StringIO tsv_string = '1\t2\t3\n' f = StringIO(tsv_string) But how do I adapt this to include null / None values? I am asking because I am generating my tsv_string…
turnip
  • 2,246
  • 5
  • 30
  • 58
0
votes
0 answers

ValueError using plt.savefig() and cStringIO buffer

I am trying to make an interactive plot of the tangent line using matplotlib and cv2. Before, I was just saving the files to my disk, then opening the images as .png into a list of images. I decided to omit using the disk and use a cStringIO buffer.…
ThisGuyCantEven
  • 1,095
  • 12
  • 21
0
votes
1 answer

Python Capture reply from powershell

The code below works when typed manually however when I run the program.py nothing prints. My ultimate goal is to retrieve this data from user pc to create an easy way to recreate shortcuts.... My users somehow lose them lol import smtplib, os,…