I am forced to ask this question My mentor has given me a task to extract data from files with pure python, there were some txt file which were easy but there is a file with xlsx extension and I can’t find any where if it is possible to extract the data from it with pure python (I have been
Tag: python-3.x
Why does my python return value include previous print text?
I have created a small python script which I call from another shell script to calculate average value from the data in a file and I’m returning this average value back to a shell script variable. Here’s my code: However, when I print the value stored in the shell variable it shows the previous pr…
Exact output was coming but some error was raising
In the above Python code the exact output was coming but after output they were showing some error Here we are giving input as The Error was Here VIP is the output For Question and test cases please refer below link https://drive.google.com/file/d/1cXmIW56uurB83V4FNRuNw9VhJ7RcYU9j/view?usp=sharing Answer if y…
python run multiple scripts
Hi i would like to run add1.py and add2.py simultaneously and have searched BAT file and SH file but couldnt do it myself. Anyone can help me? The folder is in the following path C:UsersJiaDownloadsTelegram BotScripts I might also add more scripts like add3.py add4.py and the list goes on. Does anyone have si…
How to escape unicode special chars in string and write it to UTF encoded file
What I aim to achieve is to: string like: convert to: and write it in this form to file (which is UTF-8 encoded). Answer Another solution, not relying on the built-in repr() but rather implementing it from scratch: Differences: Encodes only using u, never any other sequence, whereas repr() uses about a third …
Transform matrix adjacency to Source, Target, Value in CSV file (python)
I have this CSV file, with adjacency matrix: I want to transform to a new csv file, with the values of sorce, target, and value. For example: Thanks! Answer If you replace the zeros with nan, you can use stack to achieve this. Output
Python Flask Executor | How to pass results from a background task to a currently active html page
To setup a simple html front-end and python flask back- Create a html script (index.html) and save D:Projectstest_backgroundtasktemplatesviews Create a python script and save D:Projectstest_backgroundtask: Code To create a background task, flask has a package called flask_executor Updated python script using …
Creating custom JSON from existing JSON using Python
(Python beginner alert) I am trying to create a custom JSON from an existing JSON. The scenario is – I have a source which can send many set of fields but I want to cherry pick some of them and create a subset of that while maintaining the original JSON structure. Original Sample Here the sData array ta…
Python keyboard module error: TypeError: ‘NoneType’ object is not callable
My code is: I ran it as root. When I press a key, it prints the key as intended. But, when I press any key right after it, it just returns an error, like this: and it keeps print out errors like that, don’t matter what key I pressed. Please help. Answer not reading the docs be like The function
Shift column position to right based on criteria using Pandas
I have a dataframe that looks like below I would like to position shift by 1 cell to the right if there is NA in the column dep_id. I tried the below but it wasn’t working Any efficient and elegant approach to shift column position on big data? For example, I expect my output to be like as shown below