unix

Split a csv file into multiple files based on a pattern

Split a csv file into multiple files based on a pattern Question: I have a csv file with the following structure: time,magnitude 0,13517 292.5669,370 620.8469,528 0,377 832.3269,50187 5633.9419,3088 20795.0950,2922 21395.6879,2498 21768.2139,647 21881.2049,194 0,3566 292.5669,370 504.1510,712 1639.4800,287 46709.1749,365 46803.4400,500 I’d like to split this csv file into separate csv files, like the following: File 1: time,magnitude …

Total answers: 4

The question of unix symbolic inspired from the usage of python venv executable symlink

The question of unix symbolic inspired from the usage of python venv executable symlink Question: Question brief description After creation of venv (either via python -m venv .venv/ or virtualenv .venv/), a files tree will be created. There is a file .venv/bin/python or python3, python3.<x>. It is a unix symbolic link to /usr/bin/python. But how …

Total answers: 1

Twisted application ignoring a certain UNIX signal – is it possible?

Twisted application ignoring a certain UNIX signal – is it possible? Question: Let’s say we have the following situation: kill <pid> sends SIGTERM kill -<SIGNAL> <pid> sends <SIGNAL> Sometimes, during development, I need to kill my application and restart it, at the moment – using the first type of command. But, if I have a …

Total answers: 2

Replace portion of fasta headers

Replace portion of fasta headers Question: I would like to replace a portion of the headers in a fasta file (surrounded by _) using a text file with a key. #fasta file: >mir-2_scf7180000350313_41896 CCATCAGAGTGGTTGTGATGTGGTGCTATTGATTCATATCACAGCCAGCTTTGATGAG >mir-92a-2_scf7180000349939_17298 AGGTGGGGATGGGGGCAATATTTGTGAATGATTAAATTCAAATTGCACTTGTCCCGGCCTGC >mir-279a_scf7180000350374_48557 AATGAGTGGCGGTCTAGTGCACGGTCGATAAAGTTGTGACTAGATCCACACTCATTAAG #key_file.txt scf7180000350313 NW_011929472.1 scf7180000349939 NW_011929473.1 scf7180000350374 NW_011929474.1 #expected result >mir-2_NW_011929472.1_41896 CCATCAGAGTGGTTGTGATGTGGTGCTATTGATTCATATCACAGCCAGCTTTGATGAG >mir-92a-2_NW_011929473.1_17298 AGGTGGGGATGGGGGCAATATTTGTGAATGATTAAATTCAAATTGCACTTGTCCCGGCCTGC >mir-279a_NW_011929474.1_48557 AATGAGTGGCGGTCTAGTGCACGGTCGATAAAGTTGTGACTAGATCCACACTCATTAAG Asked By: …

Total answers: 2

How to loop and index through file content in python and assign each line for different variable

How to loop and index through file content in python and assign each line for different variable Question: If I have a file.txt And the content looks like this: BEGAN_SIT s_alis=’HTTP_WSD’ xps_entity=’HTTP_S_ER’ xlogin_mod=’http’ xdest_addr=’sft.ftr.net’ xmax_num=’99’ xps_pass=’pass’ xparam_nm=’htp’ #?SITE END How i I can loop through it and assign each line for different variable Asked By: …

Total answers: 1

How to run a Python program ona specific CPU core

How to run a Python program ona specific CPU core Question: Say I have a python file – file1.py with arg –in python file1.py –in 10 I have an 8-core Unix machine, I want to run the same script 8 times (infinite loop) (diff –in value) which should run in 8 different cores, like python …

Total answers: 1

ModuleNotFoundError: No module named 'pandas' – when I have pandas already installed

ModuleNotFoundError: No module named 'pandas' – when I have pandas already installed Question: I am trying to run some Python code via a Bash script (launch.sh). It looks like the Bash script starts to run, but then I get the error returned: `ModuleNotFoundError: No module named ‘pandas’ Below you can see that I have Pandas …

Total answers: 2

Python2.7 ~ tilde not recognized in path as home directory macOs

Python2.7 ~ tilde not recognized in path as home directory macOs Question: At some point the tilde symbol ~ was no longer recognized as my home directory, only in Python. ~ still works with in terminal, so I’m not sure what happened but any insight on how to fix it you will save me some …

Total answers: 2

Python multiprocessing – AssertionError: can only join a child process

Python multiprocessing – AssertionError: can only join a child process Question: I’m taking my first foray into the python mutliprocessing module and I’m running into some problems. I’m very familiar with the threading module but I need to make sure the processes I’m executing are running in parallel. Here’s an outline of what I’m trying …

Total answers: 3

disable the automatic change from rn to n in python

disable the automatic change from rn to n in python Question: I am working under ubuntu on a python3.4 script where I take in parameter a file (encoded to UTF-8), generated under Windows. I have to go through the file line by line (separated by rn) knowing that the "lines" contain some ‘n’ that I …

Total answers: 2