Skip to content

Tag: perl

Parse text with uncertain number of fields

I have a file (~50,000 lines) text.txt as below, which contains some gene info from five individuals (AB, BB, CA, DD, GG). The t in the file is a tab seperator. There are also a lot of info that are not useful in the file, and I would like to clean it up. So What I need is to extract

Trying to run python script in PHP

I’m trying to run a Python script inside a perl script with the following command: On the operating system’s command line, the Python script executes, but when I make a call from a PHP application, the perl work, but the python script don’t work. Answer Do you get any error message from Perl…

Remove duplicates from each cell

I have a file like this and need to remove duplicates in each cell without changing the order or format The missing data are noted as . (dot). So far I have tried with awk But it is killing the format. Is there any other way to do this ? Expected output Answer with sed

Counting dictionary elements from Perl to Python

Looking for a best way to translate this piece of code from Perl to Python: If I understand it correctly the cycle above iterates through each element in arr array and how many time host appear, how many bytes count are related to it and errors… But I don’t quite get the meaning of default variabl…

How to efficiently calculate a running standard deviation

I have an array of lists of numbers, e.g.: I would like to efficiently calculate the mean and standard deviation at each index of a list, across all array elements. To do the mean, I have been looping through the array and summing the value at a given index of a list. At the end, I divide each value in