Modifying and creating xlsx files with Python, specifically formatting single words of a e.g. sentence in a cell

Uncategorized
Question: I'm working a lot with Excel xlsx files which I convert using Python 3 into Pandas dataframes, wrangle the data using Pandas and finally write the modified data into xlsx files again. The files contain also text data which may be formatted. While most modifications (which I have done) have been pretty straight forward, I experience problems when it comes to partly formatted text within a single cell: Example of cell content: "Medical device whith remote control and a Bluetooth module for communication" The formatting in the example is bold and italic but may also be a color. So, I have two questions:Is there way of preserving such formatting in xlsx files when importing the file into a Python environment? Is there of creating/modifying such formatting using a specific…
Read More

Call php function via ajax when user navigates away from page

Uncategorized
Question: I have a web app where I need to call a php function with parameters when the user navigates away from the page. This functionality doesn't need to be too sophisticated, simply when the user clicks another link on the page or goes to a different URL should suffice. Needed for a CRUD app to release the record lock which is executed via the function call (sproc wrapper). php code if (isset($_GET['modify'])) { .... } else { // Putting the function here causes excessive calls } wrapper function record_lock($row_id, $username, $end_lock){ $stmt = mssql_init('spRecordLocks'); mssql_bind($stmt, '@RowId', $row_id, SQLVARCHAR, false, false, 50); mssql_bind($stmt, '@Username', $username, SQLVARCHAR, false, false, 50); mssql_bind($stmt, '@EndLock', $end_lock, SQLVARCHAR, false, false, 50); $result = mssql_execute($stmt); $array = return_array($result, $stmt); return $array; } After researching, seems I…
Read More

Google query send function not doing anything

Uncategorized
Question: I'm trying to do a google sheet query but I can't get the code working when I follow the instructions on Googles query language reference page. (developers.google.com/chart/interactive/docs/querylanguage) it says: To set the query string from within JavaScript code, call the setQuery method of the google.visualization.Query class. var query = new google.visualization.Query(DATA_SOURCE_URL); query.setQuery('select dept, sum(salary) group by dept'); query.send(handleQueryResponse); My sheet is here: docs.google.com/spreadsheets/d/1DQZOdU0fHdEH9LS05D2-lYkFHpgfQ95lVgvkUI_NujU/ and sheet query works fine like this: docs.google.com/spreadsheets/d/1DQZOdU0fHdEH9LS05D2-lYkFHpgfQ95lVgvkUI_NujU/gviz/tq?tq=select%20A My code is here:console.log("started") var src_url = "https://docs.google.com/spreadsheets/d/1DQZOdU0fHdEH9LS05D2-lYkFHpgfQ95lVgvkUI_NujU" var query = new google.visualization.Query(src_url); query.setQuery('select A'); query.send(handleQueryResponse); function handleQueryResponse(response){ console.log("handling query") } I get the "started" message in console ok but I can't understand why the send function doesn't do anything? When I try to run the code I get nothing. Not error in console no console messages (besides…
Read More

python DataFrame: get 'set' from DataFrame elements

python
Question: How can I get 'set' data from DataFrame elements? For example, if I have a data as df = DataFrame([['a','b','z'], ['a', 'c'], ['d']]) I would like to get {'a', 'b', 'c', 'd', 'z'} (type: set) If I use for sentence, I can code it. However, if there is another way to calculate with pandas, I would like to use it. Answer: DataFrame.stack(dropna=True) per default drops all NaNs In [56]: df.stack().tolist() Out[56]: ['a', 'b', 'z', 'a', 'c', 'd'] or as a set:In [57]: set(df.stack().tolist()) Out[57]: {'a', 'b', 'c', 'd', 'z'} Read more
Read More

(Image Processing) Extract texture and fill the empty region

Uncategorized
Question: I have an image: AND I want it to become : so that the vacant region also filled with the same texture of image. This is the example to show problem. I don,t want to just cut a portion from image and paste it repeatedly on the vacant portion. it will distort the symmetry of image. I want to get this type of result on this image: What are the solution from which I can achieve this solution. Please help if anybody know anything about this problem. Answer: Read more
Read More

Drools: Firing a rule if a set of events has n distinct values for a property

Uncategorized
Question: Suppose we have an Event type that has 3 properties: constraint, common, and distinct. The goal is to write a rule in Drools that fires when a subset of Events exists that meets the following criteria:Events happened in the last t seconds; and Events Have a previously known value for constraint property; and Share a previously unknown value for common property; and There are at least n different values for distinct property If the rule fires, we need the set of participating events for further processing. How do you advise we approach this problem? Note 1: This question is somewhat similar to link, and Steve's answer there seems promising but is incomplete. Note 2: Performance is of the essence. We have successfully developed rules that do this task, but…
Read More

match criteria and repeat value

Uncategorized
Question: I'm trying to create a dynamic formula to match the Location and start_time and copy the value based on the replicate count. I'm able to index/match location and start_time to get the value but unable to include a dynamic formula to have the value replicate Sample Data: Ideal Outcome: Any suggestions would be appreciated! Answer: So you already know where the first value should go, so I'll leave that to you. To fill the voids in between you could use a formula like this:=IF(ROW()-1="";"";IF(ROW()
Read More

Is gcc reordering my volatile variables?

Uncategorized
Question: I am developping on an STM32F746 (ARM Cortex-M7) with the GNU ARM Toolchain (gcc 5.4.1) using FreeRTOS. I am using the following CFLAGS set:-g -Werror -Wextra -O2 -fno-common -ffunction-sections -fmessage-length=0 -g -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -fno-common -ffunction-sections -fmessage-length=0 -g -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 The following code shows '0' in the console as if the DMA controller was not powered on. Normally, writing RCC_AHB1ENR_DMA1EN in the AHB1ENR register power on the DMA controller. /* *** Other peripheral configurations *** */ RCC->AHB1ENR |= RCC_AHB1ENR_DMA1EN; DMA1_Stream3->CR = DMA_SxCR_PL | DMA_SxCR_MINC | DMA_SxCR_TCIE | DMA_SxCR_TEIE | DMA_SxCR_DMEIE; DEBUG_PRINTF("%xrn", DMA1_Stream3->CR); But the following code is printing the good value of DMA1_Stream3->CR. /* *** Other peripheral configurations *** */ RCC->AHB1ENR |= RCC_AHB1ENR_DMA1EN; __asm__ __volatile__ ("" ::: "memory"); DMA1_Stream3->CR = DMA_SxCR_PL | DMA_SxCR_MINC | DMA_SxCR_TCIE |…
Read More