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

How to stop mails to be sent if the attachment data is empty in python?

I am writing a mail function in Python using csvwriter and StringIo, my motive is to send the mails with attachment only if the attachment is containing some data. But, the function is also sending mails in case of empty file. Please help me where i…
0
votes
1 answer

Python Pillow: Make image progressive saving to model

I asked a relative question previously, regarding pillow. Python Pillow: Make image progressive before sending to 3rd party server Just to extend this, How can I achive the progressiveness into the image when I am uploading an image and storing it…
A.J.
  • 8,557
  • 11
  • 61
  • 89
0
votes
1 answer

Using StringIO with pandas.read_csv keyword arguments

I am attempting to read in a csv file using pandas.read_csv. I am very confused, since the code works when one types in the csv manually. from six.moves import cStringIO as StringIO Companies=""" Top, Equipment, Users, Neither Company 1, …
jenryb
  • 2,017
  • 12
  • 35
  • 72
0
votes
1 answer

retrieving string from file in python and changing tuples

I have a serious snag in my programming, and it might be an easy fix, but anytime I find something that looks like the right forum post, it's not quite right. I'm using a file to store data created from one part of my program, like a high score,…
Ryan Harger
  • 47
  • 1
  • 9
0
votes
2 answers

Invoking perl script with variable input and file output as arguments from python

I have a perl script that can be executed from the console as follows: perl perlscript.pl -i input.txt -o output.txt --append I want to execute this script from my python code. I figured out that subprocess.Popen can be used to connect to perl and…
0
votes
1 answer

after PIL.Image.tostring() "cannot identify image file"

I want to use an string for storing image data. Background: In some other parts of the code I load Images, which were downloaded from the web, and stored as string using imgstr =…
BerndGit
  • 1,530
  • 3
  • 18
  • 47
0
votes
1 answer

MozJPEG STDIN Mode with switches

I'm able to get stdin/out working just fine with mozjpeg 3 if I just run without any flags. Example(Python): fp = urllib.urlopen(http://path.to/unoptimized.jpg) out_im2 = StringIO.StringIO(fp.read()) # StringIO Image subp =…
ryan83
  • 13
  • 4
0
votes
1 answer

StringIO getvalue raising UnicodeDecodeError when printing traceback

The call: deprint(_(u'Error finding icon for %s:') % target.s, traceback=True) where: def deprint(*args,**keyargs): # msg = u'' try: msg += u' '.join([u'%s'%x for x in args]) except UnicodeError: # If the args failed to…
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
0
votes
1 answer

JpegImageFile instance has no __call__ method with StringIO

When I get a binary file from server I access it via r.content. The problem is I want to turn this binary to image and then send it to browser as below: i = Image.open(StringIO(r.content)) But calling this would return the following error: …
Alireza
  • 6,497
  • 13
  • 59
  • 132
0
votes
1 answer

printing string to HTML page in python

I wrote a python code that returns a StringIO which consists of several lines extracted from a runlog. Then it writes this string in a .txt file and an html page. the format of the lines in the .txt file shows every line of the runlog seperately,…
bush
  • 9
  • 4
0
votes
1 answer

After sending image to client I get gibberish instead of picture

I allow a client which connects to my python - server to ask for a picture. I return him a fixed http which includes the binary data by the following code (ignore bad identication): if os.path.isfile(PICROOT + pic_name): with…
Danis Fischer
  • 375
  • 1
  • 7
  • 27
0
votes
1 answer

Python: How to download a webfile into the memory?

[In order to open the example urls you need to login to Shazam] So I'm writing a script that downloads my Shazam history so I can then manipulate it to write playlists to other services. Anyways, I can't directly parse the history from…
whoisjuan
  • 437
  • 1
  • 6
  • 15
0
votes
3 answers

Selecting columns based on external list/data in python

I have a data set with various Region map variables(around 1000). Sample data looks like: Userid regionmap1 regionmap2 regionmap3 and so on. 78 7 na na 45 na na na 67 1 na …
user2007506
  • 79
  • 2
  • 8
0
votes
1 answer

Converting a string containing binary operations to a double in C++

I have the following intention: Take a string such as: string test = "2.0+2.5"; and convert this to the double 4.5. Is this possible? I also want to extend this to the complex type. I have more experience with Java but I am trying to work with…
anon1001
  • 107
  • 6
0
votes
3 answers

Python - Converting long list of addresses into list of strings and intersection of lists

I have two very long text files (thousands of e-mail addresses, one per line) an I'm looking for a way to compare the two files and have an output with the adresses contained in the first file and in the second file but not in both of them…
DavideL
  • 294
  • 1
  • 3
  • 15