io

writing Yaml file in python with no new line

writing Yaml file in python with no new line Question: Let’s say I have the following snippet : import yaml Key = ["STAGE0", "STAGE1"] dict = {} dict[Key[0]] = [‘ ‘] dict[Key[1]] = [‘ ‘] dict[Key[0]][0]="HEY" dict[Key[0]][0]="WHY newline?" with open("SUMMARY.YAML", "w") as file_yaml: yaml.dump(dict, file_yaml) The output SUMMARY.YAML file looks like this : STAGE0: – …

Total answers: 2

Keep extra whitespaces while writing pandas dataframe to file

Keep extra whitespaces while writing pandas dataframe to file Question: How do I keep extra whitespaces from columns while writing a dataframe to a file? Say I have this dataframe, while printing the dataframe I can see the whitespaces. to_csv() from pandas, however, strips the whitespaces while writing to file. Whitespaces are even preserved, if …

Total answers: 1

how to combine common values from 2 txt files into 1 file using python

how to combine common values from 2 txt files into 1 file using python Question: I’m not sure how to write a script to combine values in 2 separate txt files using the specific tag of not done and ensure there are no duplicates. I currently have 2 files with lists of filenames. Each of …

Total answers: 1

Avoiding IO time delay in a loop using multiprocessing

Avoiding IO time delay in a loop using multiprocessing Question: I am running prediction using a trained tensorflow model and generating data using it on the images coming from a simulator. But the issue here I need to save image too for each prediction I am making which is creating delay in the loop sometime …

Total answers: 1

How to achieve concurrency with two threads with different execution times?

How to achieve concurrency with two threads with different execution times? Question: I am working on a school project. I set some rules in iptables which logs INPUT and OUTPUT connections. My goal is to read these logs line by line, parse them and find out which process with which PID is causing this. My …

Total answers: 1

FastAPI – ValueError: raw stream has been detached

FastAPI – ValueError: raw stream has been detached Question: My API is working properly from the client’s side, as it returns the expected response, but it bothers me that I get a logging error as below from the server side. I failed to figure out what’s this error about and how to prevent this from …

Total answers: 1