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

What uniformly replaces the StringIO of Python2 in Python3?

The documentation suggests that BytesIO is the new StringIO, because it supports current-relative seeks. However, this is incorrect. BytesIO cannot be used uniformly with TextIOWrappers as they are returned by open() calls. The former returns…
Frank-Rene Schäfer
  • 3,182
  • 27
  • 51
0
votes
0 answers

Unable to decode the base64 string - Python3.7

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import boto3 >>> import json >>> import gzip >>> import time >>> from io…
0
votes
1 answer

NotFittedError: This BalancedRandomForestClassifier instance is not fitted yet. Call 'fit' with appropriate arguments before using this method

I am trinyg to plotting my model but the code is error which model is not fitted yet. But i fitted the model. Can someone help me to why i'm getting this error? My code is below; model = BalancedRandomForestClassifier(n_estimators = 200,…
0
votes
1 answer

Save DataFrame to csv encounters error "ImportError: cannot import name 'StringIO'"

I have a pandas DataFrame output_df that I can manipulate or print without problems. However, when I run output_df.to_csv(output_filename), it gives an error: File "my_file.py", line 169, in run_attribute_generator …
F.S.
  • 1,175
  • 2
  • 14
  • 34
0
votes
0 answers

How to upgrade a io.stringio to file as w

https://docs.python.org/3.7/library/io.html#text-i-o says that io.Stringio is created inside of an open() file object. If I want to start with a Stringio and then flush it into a file object how would I do that? Obviously I could just open the new…
9716278
  • 2,044
  • 2
  • 14
  • 30
0
votes
1 answer

Flask - Problems with Sending Zipped Folder Back To User

I'm trying to send an excel file back to the user's browser in a zipped folder. I build the excel file(s) using openpyxl , and here is my code : @app.route('/test', methods=['GET', 'POST']) def test(): # ... from zipfile…
pablowilks2
  • 299
  • 5
  • 15
0
votes
2 answers

How to return string value of Console output to put it into a label in Tkinter

I made a python script that has a lot of print statements showing what the program is doing rather than just having it just sit there and the python script works fine now I am creating a front end with tkinter. What I used to send the print…
David Long
  • 39
  • 6
0
votes
1 answer

Django CSV upload UploadForm to database Clean

i would like to store the data from my uploaded CSV file, called data_file I cant loop over the rows by column name in my csv file. I get Encoding errors(UTF, ASCII), also when i use IO String. I am new to django so i dont know what i do…
Pearl
  • 39
  • 7
0
votes
0 answers

pyspark write spark dataframe as single partitioned csv to stringio for ftp

I would like to write a spark dataframe to stringIO as a single partitioned csv. This singled-partioned csv is then supposed to be sent to another server using ftp. the following line does not seem to…
C.Tomas
  • 451
  • 2
  • 7
  • 15
0
votes
0 answers

Error inputting string into a pandas dataframe?

I'm trying to create a dataframe using outputs from the pysam module which is used on genomic data (Bam/Sam files). Pysam.depth() outputs a table as a string. I have used the module StringIO to try to parse the string into a pandas dataframe,…
0
votes
1 answer

How to redirect the stdout of a multiprocessing.Process

I'm using Python 3.7.4 and I have created two functions, the first one executes a callable using multiprocessing.Process and the second one just prints "Hello World". Everything seems to work fine until I try redirecting the stdout, doing so…
0
votes
1 answer

How to send a dataframe as a CSV from Memory Using StringIO

I'm trying to send a pandas dataframe as a CSV attachment in an email. My code is not throwing an error. However, the resulting email contains an empty attachment. Am I missing something? I am using mailgun api for email and have tried the following…
pablowilks2
  • 299
  • 5
  • 15
0
votes
1 answer

Creating ZIP file in Memory and sending via POST request

I am attempting to create a zip file in memory with python that I will then attach to a POST request to send with python-requests. Here is the function I wrote import StringIO,zipfile code = "poopootest" def _build_zip_inmem(code): mf =…
D3l_Gato
  • 1,297
  • 2
  • 17
  • 25
0
votes
2 answers

How to manipulate, filter columns with TextFileReader?

I have a massive 8GB CSV file that contains information about companies created in France. I managed to read the file in python using: df = pd.read_csv('File', sep=";", encoding="latin", iterator = True, chunksize=1000) I know that this code…
Siva Kg
  • 59
  • 8
0
votes
0 answers

Python 3 with CSV reader and StringIO using excessive memory

The CSV file here is about 500MB with 2.7 million rows. Through extensive testing, I have verified that for row in read_new: quadruples memory consumption, and I can't understand why. The memory increase does not happen before or after the for…
OnNIX
  • 422
  • 4
  • 10