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
0 answers

Python Print to String

I have some code that works perfectly, but am now trying to move it into a GUI. The issue so far is that I'm using pygame, and I have so far only managed to show text from a single assigned string. # --- calculate all variables for i in range(0,…
0
votes
1 answer

Creating a zip file in stream without directory structure

I'm working on a Flask app to return a zip file to a user of a directory (a bunch of photos) but I don't want to include my server directory structure in the returned zip. Currently, I have this : def return_zip(): dir_to_send =…
James Watson
  • 35
  • 1
  • 4
0
votes
0 answers

How to solve error: No columns to parse from file for StringIO()

When i try to run the code i get error : EmptyDataError Traceback (most recent call last) in 1 csv2 = StringIO(transactions) 2 csv2.seek(0) ----> 3 df2 = pd.read_csv(csv2, sep='\t') 4 print(df2) 6…
biGmazi
  • 11
  • 3
0
votes
1 answer

Used dropna(subset) but an error occurred

I'm practicing on data preprocessing using dropna method I simply defined csv_data as csv_data = \ '''A, B, C, D 1.0, 2.0, 3.0, 4.0 5.0, 6.0,, 8.0 10.0, 11.0, 12.0,''' df = pd.read_csv(StringIO(csv_data)) And I tried df.dropna(subset=['C']) for…
Crackerslover
  • 13
  • 1
  • 4
0
votes
1 answer

Paramiko No such file or directory: '-----BEGIN RSA PRIVATE KEY-----\n'

I am coming across issues using the SSHHook class in a DAG. The error is File "/usr/local/airflow/.local/lib/python3.7/site-packages/paramiko/pkey.py", line 307, in _read_private_key_file with open(filename, "r") as f: FileNotFoundError:…
rk92
  • 551
  • 4
  • 21
0
votes
1 answer

cannot identify image file %r" % (filename if filename else fp)

I am trying to download an image using PIL but its shows an UnidentifiedImageError d = login_session.get("https://example.com/xyz.php") d = Image.open(BytesIO(d.content)) d.save("xyz.png") Here I need to log into a site first and then download an…
dx4iot
  • 53
  • 1
  • 8
0
votes
1 answer

How to get rid of '\r' when exttracting and printing a table from a pdf file?

The Objection is to extract a table from a given PDF file and convert the whole table to an pd dataframe for further operations. Obviously, the whole table will only contain strings in it. While the code itself is working, when converting the…
0
votes
2 answers

Basic Python StringIO -- Why is GetValue() Returning Nothing?

I'm having basic python issues.. In the following example no errors are returned but displaying the contents of all variables using pprint shows that contents is = '' -- why would this possibly be the case? import sys, os, re, StringIO, pprint,…
Alexander Cameron
  • 309
  • 1
  • 4
  • 11
0
votes
1 answer

reading logfiles with pandas (tab/ newline separated, each row contains a column and value)

I am processing log files with pandas with the following structure, all log files have the same structure and contain data about one machine that should be reducable to 1 row: Column1 Value1 Column2 Value2 Column3 Value3 Column4 …
Stijn
  • 121
  • 9
0
votes
0 answers

Ruby PDF generation with CombinePDF & StringIO removes "<" character

I can't for the life of me figure out how to make < show up in pdf generation using CombinePDF & StringIO. > shows up fine in the generated pdf but not <. I can't easily change the software I'm using and would ideally escape "<" so that it still…
Sam H.
  • 33
  • 1
  • 10
0
votes
0 answers

Chaining Python StringIO

Is there a means by which I can add processing to an io.TextIOBase subclass and produce another io.TextIOBase subclass? For example, if I want to convert from a string of Octal characters to Binary characters, I could do this with a generator…
Richard Vodden
  • 318
  • 3
  • 12
0
votes
1 answer

Pandas merge not working after using StringIO

I need to convert a string into a pandas DataFrame to further merge it with another DataFrame, unfortunately the merge is not working. str_data = StringIO("""col1;col2 one;apple two;lemon""") df = pd.read_csv(str_data, sep =";") df2 =…
ZetDen
  • 155
  • 8
0
votes
0 answers

Is it possible to fake user inputs not in testing

I have developed a game that basically moves on a Cartesian coordinate system. Now to spare you all having to read through all the code I wrote( simply because I am still new and its very bad haha)I will simply ask the question. I read somewhere…
0
votes
1 answer

Preserve one column in timestamp format when write pd.to_csv

I need to write the following dataframe to csv: prodid value timestamp 322 4 2021-11-03 17:32:12.252 123 34 2021-11-03 18:42:12.602 ... or import datetime df = pd.DataFrame([(0, 4,…
Tristan Tran
  • 1,351
  • 1
  • 10
  • 36
0
votes
1 answer

Python3 streaming string replacement

I have a python3 "file-like object" whose read() method returns a string - it comes from either an opened file or an object streamed from s3 using boto3. I want to sanitize the stream before passing it to csv.DictReader, in particular because that…
e.dan
  • 7,275
  • 1
  • 26
  • 29