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

Generating ZipFile with List of StringIO Object, CRC Error when Opening the ZipFIle

I am currently facing some difficulty regarding generating Text file with multiple line of text and add it to a ZipFile in memory with Python 2.7. The code below is able to generate zip file with 4 text file, each file have 1 line of words. If I…
guyz92
  • 15
  • 4
0
votes
0 answers

How to get type 'NoneType' to print out as a string to an external file? (Python 2.7)

I have a datalib method that is type 'NoneType' and it behaves oddly: >>> print ISC_MSG None >>> ISC_MSG = (ISC.message("INFO", MESSAGE = 'test' )) INFO (I) test >>> ISC_MSG >>> I'd like to print "INFO (I) test" to an external…
Cookies Monster
  • 121
  • 1
  • 7
0
votes
1 answer

How to subprocess the files on console directly (with or without using StringIO)?

I am trying to read a gtf file and then edit it (using subprocess, grep and awk) before loading into pandas. I have a file name that has header info (indicated by #), so I need to grep that and remove it first. I can do it in python but I want to…
everestial007
  • 6,665
  • 7
  • 32
  • 72
0
votes
1 answer

Converting scraped text into Pandas data frame with BeautifulSoup

I am extracting some text from a website using the code below. I have it in the form of a string. import requests URL = 'https://www.instituteforsupplymanagement.org/about/MediaRoom/newsreleasedetail.cfm?ItemNumber=30655&SSO=1' r =…
prashanth manohar
  • 531
  • 1
  • 13
  • 30
0
votes
0 answers

Truncating String.IO() won't take affect

So I am making a flask app to build team configurations using a backtracker. Everything on the backend is fine but I am having trouble serving the content. This is not a production thing, just a script for me and my friends. I capture stdOut into a…
0
votes
1 answer

python, when use writestr there is a text newline issue

I need your help~ I have a LF problem when I use 'wirtestr'. the text have been written into zip well but It comes in one line without line breaks. Only I could find the delimiter which looks like square has circle in the middle of it, maybe hex…
j.lim
  • 3
  • 3
0
votes
1 answer

logger.info / logger.error with logger.addHandler - how to split streams?

So I'm putting .info in one StringIO and .error in another StringIO. How do I stop them from both being put into both? Prelude: from __future__ import print_function import logging from io import IOBase from sys import stdout from platform import…
A T
  • 13,008
  • 21
  • 97
  • 158
0
votes
1 answer

OSError: cannot identify image file <_io.StringIO object at 0x00000000022810D8>

Use win8 and python3.4,I need to convert text to images.So I try to implement a himself.But I encounter a OSError.I try to use BytesIO instead of StringIO,it will pop error "OSError: cannot identify image file <_io.BytesIO object at xxxx>. I still…
Moon
  • 1
  • 2
0
votes
1 answer

Write non-Unicode using csv module

While migrating to Python 3, I noticed some files we generate using the built-in csv now have b' prefix around each strings... Here's the code, that should generate a .csv for a list of dogs, according to some parameters defined by export_fields…
Maxime Lorant
  • 34,607
  • 19
  • 87
  • 97
0
votes
1 answer

Sending multiple .CSV files after zipping them and without saving to disk

I am trying to retrieve files from the internet, save them as dataframe (without saving the files on computer), do some calculation, save resulting dataframes in the required format as csv files, zip them and send them back to the orginal source(see…
Muhammad
  • 305
  • 2
  • 6
  • 20
0
votes
0 answers

TypeError on importing dict to dataframe

Any tips on importing lxml.etree start event into pandas.DataFrame. The following code shows simple lxml parsing and converting entries into dataframe (pandas) using from_records. [NOTE: I tried from_dict but it needed a list per attribute while…
frankr6591
  • 1,211
  • 1
  • 8
  • 14
0
votes
1 answer

Python: Mapping error for a StringIO converted csv dataframe versus pandas data frame?

I realised that there's a problem with mapping a column when I created a dataframe using the pd.read_csv and StringIO, to convert a string of text into a dataframe then mapping a specific column with a dictionary, as the column will give me all NaN…
kwotsin
  • 2,882
  • 9
  • 35
  • 62
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,…
0
votes
1 answer

writing StringIO back to disk in python

I created an in-memory zip file using StringIO and zipfile: inMemoryZip = StringIO() outfile = zipfile.ZipFile(inMemoryZip, 'w', compression=zipfile.ZIP_DEFLATED) //outfile.write(stuff) inMemoryZip.seek(0) return inMemoryZip This data is uploaded…
Abdul Ahmad
  • 9,673
  • 16
  • 64
  • 127
0
votes
1 answer

Error 2 No such file or directory in pytesseract

I want try to read the simple image But I have the follwoing error: import requests import pytesseract from PIL import Image from StringIO import StringIO from lxml import…
MLSC
  • 5,872
  • 8
  • 55
  • 89