Comment by dbc on Downloading image with PIL and requests
That would work, but using TemporaryFile will actually write the bytes to disk as they come in. Using SpooledTemporaryFile will keep the bytes in memory, and therefore might be faster--and it's what...
View ArticleComment by dbc on InnoSetup - How to detect if MySQL Workbench is installed?
I added more information about what I'm trying to do to the question.
View ArticleComment by dbc on How to open a PDF with Inno Setup on Windows 10?
No luck, passing '' to ShellExec has the same result. However, that's good to know that read is the new default action, thanks.
View ArticleComment by dbc on REPLACE rows in mysql database table with pandas DataFrame
That's a good point; the second line is only needed if the df has an index set on one or more columns.
View ArticleComment by dbc on converting ascii to sac using python
Welcome to StackOverfow, BitaNajd! It's best to answer questions with more than just a link. What exactly at that link are you referencing? What wasn't working in the OP's code, and what did you change...
View ArticleComment by dbc on MYSQL Select rows from table with staggered ID
I've updated the answer to include a solution for MySQL 5.7. In the future, you should specify which version your question is specifically about, otherwise people will generally assume you are using...
View ArticleAnswer by dbc for How can I change the cursor shape with PyQt?
While Cameron's and David's answers are great for setting the wait cursor over an entire function, I find that a context manager works best for setting the wait cursor for snippets of code:from...
View ArticleAnswer by dbc for Creating a toggling "Check All" checkbox for a ListView
In case it will help others, here's how I incorporated Brendan's answer in my code. The differences are the tristate functionality is enabled only when needed (so the user can't enable the...
View ArticleCreating a toggling "Check All" checkbox for a ListView
I have a ListView full of checkable items. I want to place a tristate "check all" checkbox above the ListView, and I want this checkbox to be bi-directional. That is, if the user toggles the check all...
View ArticleAnswer by dbc for Deleting a line just after reading it
While I don't know why it breaks after working for 163 lines, it is probably because you have have are changing the file in delete_a_line while it is still open in the original with block. I was able...
View ArticleAnswer by dbc for Row Values to Column Array in Pandas DataFrame
Call .groupby('ItemID') on your dataframe, and then concatenate the feedback column:df.groupby('ItemID')['Feedback'].apply(lambda x: ', '.join(x))See Pandas groupby: How to get a union of strings.
View ArticleAnswer by dbc for Email scraper: saving text to text file
The problem is that input() will only read until the first new line character. If you want to read multiple lines, you need to put input() in a loop. The problem then becomes how do you know when to...
View ArticleAnswer by dbc for How to close a login dialog and show the main window (PyQt4)
The way I've solved this problem in the past is to put a function call in the main window's __init__ that displays a login dialog box (this way, the box can be skipped if credentials are stored in a...
View ArticleAnswer by dbc for How to use Python to retrieve HDF5 files
Since you want to put it in a pandas dataframe, just use pandas.read_hdf.http://pandas.pydata.org/pandas-docs/version/0.17.0/generated/pandas.read_hdf.html
View ArticleAnswer by dbc for Python: how to identify existing field value and avoid...
The pandas library is well suited for these kinds of operations.import pandas as pdfrom datetime import datetime as dtdef get_day(ob_date): weekday = dt.strptime(ob_date, ' %Y-%m-%d...
View ArticleAnswer by dbc for conditional replacement with pandas
You could set 'AZB' values to NaN, and then use fillna(method='ffill') to replace them with the values from the row above.df.ix[df['INDEX'] == 'AZB', 'INDEX'] = np.NaNdf.fillna(method='ffill',...
View ArticleAnswer by dbc for int and string errors in the class file in Python
As the error message states, len doesn't make sense with an int. If you want the number of characters in it, convert it to an str first.def __repr__(self): if len(str(self._birthDay[0]))<2:...
View ArticleAnswer by dbc for Shortening GUI code by passing parameters to definitions
Use a lambda expression to pass arguments to bound functions. For example:self.VDBenchSlot1.Bind(wx.EVT_BUTTON, lambda event: self.VDBenchSlot_clicked(event, 1))def VDBenchSlot_clicked(self, event,...
View ArticleAnswer by dbc for How to open a PDF with Inno Setup on Windows 10?
I suspect that something is going on with privileges, since the result is different depending on how the installer is launched (e.g. from an already elevated process vs. elevating after starting).Using...
View ArticleAnswer by dbc for How to communicate with Google Chrome using C# or Python
It sounds like you want to do web scraping. Here's a good tutorial to get you started: HTML Scraping.And this answer has a good example of how to scrape data from a website where you need to submit a...
View ArticleMySQL set secure-file-priv to multiple directories
Is there any way to allow MySQL to load data from multiple directories without setting secure-file-priv=''?E.g., something like: secure-file-priv="path/to/dir1","path/to/dir2"From reading the docs, it...
View ArticleAnswer by dbc for How to loop through dictionary list and extract one key...
Use the dictionary function get which has built-in error checking and allows you provide a default value in case the key doesn't exist for some values.tweets_Rt_Removed = []for tweet in tweets_data: if...
View ArticleAnswer by dbc for Python Tkinter: Call function after long press spacebar for...
I know that this is an old question, but I was able to implement a solution with a bit of trial-and-error, and thought I'd post it here in case it helps anybody else. (Note that I've only tested this...
View ArticleAnswer by dbc for Setting waitcursor on glasspane doesn't work in Dialog
I know this question is super old. However, I had the same question, and it took me a while of searching through old threads on many websites before I was able to find the solution. Posting it here to...
View ArticleComment by dbc on Close curly bracket is missing while inserting data in mysql
What language are you using? (e.g., for jsonObject.toString()) Please add that as a tag so people have a frame of reference for your question.
View ArticleComment by dbc on Having trouble by adding txt files to .EXE using...
Hi David, welcome to Stack Overflow. To help others help you, it's useful to include a minimal reproducible example of the issue you are trying to solve. Since this is with auto-py-to-exe, it would be...
View ArticleComment by dbc on How should I resolve --secure-file-priv in MySQL?
As of MySQL Server 5.7.16, commenting out the line will not work, because then it will revert to the default, which disables import and export operations. You now need to set it to an empty string if...
View ArticleAnswer by dbc for SQL query to return number of users that has a post and...
There are a number of ways this can be solved, but the most intuitive option (to me) would be to use window functions, since each column in your desired output is rather simple to calculate on its own....
View ArticleComment by dbc on What are the names associated with Python Tkinter get_focus()?
Welcome to Stack Overflow! Please remember to upvote and mark as accepted if this answer helps you.
View ArticleComment by dbc on Factor creates levels as integers and not actual strings
This is the intended behavior of factor in R. It essentially maps unique values in your data to integers, which can reduce the memory your character data takes up and speed up manipulation operations...
View ArticleComment by dbc on Java 21 problem with...
For folks on Windows using cmd and wondering "how to fix your console", this process worked for me: Windows Settings > Time & Region > Language & Region > Administrative Language...
View ArticleComment by dbc on Javafx project (fxml not loading using gridpane)
Please edit your question to specifically and clearly define the problem that you are trying to solve. Additional details, such as error messages, will help readers to better understand your problem...
View ArticleAnswer by dbc for Upgrading to Inno Setup v6 - SignTool=sha1 no longer works
I've only had luck defining the sign tool name and command through the compiler IDE for Inno Setup 6.Based on your [Setup] example, it looks like you want to have two sign tool directives set, sha1 and...
View ArticleComment by dbc on Determine level of nesting list of lists
listDepth was removed from the plotrix package in version 3.8-1. But +1 for purrr::vec_depth, which gets the job done.
View ArticleComment by dbc on Inno Setup "MoveFile Failed; code 183" (file already...
Yes, but that gives a different error (access denied). However, it turns out that the read-only attribute was a red-herring. It turns out that the error 183 was being triggered by a file having the...
View ArticleAnswer by dbc for Inno Setup "MoveFile Failed; code 183" (file already...
An error occurred while trying to rename a file in the destination directory:MoveFile failed; code 183.Cannot create a file when that file already exists.This error indicates that Inno is trying to...
View Article