extract

Accessing last x characters of a string in Bash

两盒软妹~` 提交于 2019-11-28 03:13:54
I found out that with ${string:0:3} one can access the first 3 characters of a string. Is there a equivalently easy method to access the last three characters? gniourf_gniourf Last three characters of string : ${string: -3} or ${string:(-3)} (mind the space between : and -3 in the first form). Please refer to the Shell Parameter Expansion in the reference manual : ${parameter:offset} ${parameter:offset:length} Expands to up to length characters of parameter starting at the character specified by offset. If length is omitted, expands to the substring of parameter starting at the character

Extracting table contents from a collection of PDF files [closed]

江枫思渺然 提交于 2019-11-28 03:12:46
I have a stack of PDFs - potentially hundreds or thousands. They are not all formatted the same, but any of them MAY have one or more tables with interesting information that I would like to collect into a separate database. Of course, I know I have to write something to do this. Perl is an option for me - or perhaps Java. I don't really care what language so long as it's free (or cheap with a free trial period to ensure it suits my purposes). I'm looking at CAM::Parse (using strawberry Perl), but I'm not sure how to use it to locate and extract tables from the files. I guess I do have a

How can I extract all values from a dictionary in Python?

99封情书 提交于 2019-11-28 02:56:06
I have a dictionary d = {1:-0.3246, 2:-0.9185, 3:-3985, ...} . How do I extract all of the values of d into a list l ? Pierre Bourdon If you only need the dictionary keys 1 , 2 , and 3 use: your_dict.keys() . If you only need the dictionary values -0.3246 , -0.9185 , and -3985 use: your_dict.values() . If you want both keys and values use: your_dict.items() which returns a list of tuples [(key1, value1), (key2, value2), ...] . Use values() >>> d = {1:-0.3246, 2:-0.9185, 3:-3985} >>> d.values() <<< [-0.3246, -0.9185, -3985] If you want all of the values, use this: dict_name_goes_here.values()

How to randomly extract FASTA sequences using Python?

 ̄綄美尐妖づ 提交于 2019-11-28 02:11:16
I have the following sequences which is in a fasta format with sequence header and its nucleotides. How can I randomly extract the sequences. For example I would like to randomly select 2 sequences out of the total sequences. There are tools provided to do so is to extract according to percentage but not the number of sequences. Can anyone help me? A.fasta >chr1:1310706-1310726 GACGGTTTCCGGTTAGTGGAA >chr1:901959-901979 GAGGGCTTTCTGGAGAAGGAG >chr1:983001-983021 GTCCGCTTGCGGGACCTGGGG >chr1:984333-984353 CTGGAATTCCGGGCGCTGGAG >chr1:1154147-1154167 GAGATCGTCCGGGACCTGGGT Expected Output >chr1

How do I extract bits from 32 bit number

非 Y 不嫁゛ 提交于 2019-11-28 01:39:35
问题 I have do not have much knowledge of C and im stuck with a problem since one of my colleague is on leave. I have a 32 bit number and i have to extract bits from it. I did go through a few threads but im still not clear how to do so. I would be highly obliged if someone can help me. Here is an example of what i need to do: Assume hex number= 0xD7448EAB. In binary= 1101 01 11 0100 0100 1000 11 10 1010 1011 I need to extract 16 bits, and output that value. I want bits 10 through 25. The lower 10

regex php: find everything in div

拥有回忆 提交于 2019-11-28 01:31:53
I'm trying to find eveything inside a div using regexp. I'm aware that there probably is a smarter way to do this - but I've chosen regexp. so currently my regexp pattern looks like this: $gallery_pattern = '/<div class="gallery">([\s\S]*)<\/div>/'; And it does the trick - somewhat. The problem is if i have two divs after each other - like this. <div class="gallery">text to extract here</div> <div class="gallery">text to extract from here as well</div> I want to extract the information from both divs, but my problem, when testing, is that im not getting the text in between as a result but

How can you extract Hardware ID using Python?

妖精的绣舞 提交于 2019-11-28 00:51:06
问题 How do you extract an HD and Bios Unique ID, using python script? 回答1: Go Get Microsoft's Scriptomatic Run it, Select the appropriate class from the dropdown (WIN32_BIOS) It will produce the necessary Python/WMI code for you. (It will also generate VBScript, Perl, and JScript) 回答2: Solutions that come to my mind: use Win32 Python Extensions and call Windows APIs to do that directly Use a WMI-wrapper for Python (some WMI interface code for reference) Edit : I assumed your OS was MS Windows :)

VBScript to read specific line and extract characters and store it as a variable

本秂侑毒 提交于 2019-11-28 00:27:17
I have a VB script that reads the 11th line from a text file. However from that line I need to extract characters 48 through 53 and save it as a variable. After this is accomplished I would like to use that variable and use it in a web url. Example below: Contents of the szCPUSer.dat file look like this: The script I have reads the 10th line Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile("szCPUSer.dat", ForReading) For i = 1 to 10 objTextFile.ReadLine Next strLine = objTextFile.ReadLine Wscript.Echo strLine objTextFile.Close I

Creating or assigning variables from a dictionary in Python

狂风中的少年 提交于 2019-11-27 23:35:17
I tried to ask a question normally once in here but nobody understands what I want to ask. So I've found example in PHP. // $_POST = array('address' => '123', 'name' => 'John Doe'); extract($_POST); echo $address; echo $name is there's a function like extract() in PYTHON????? So the same goes to dictionary: mydict = {'raw':'data', 'code': 500} // some magic to extract raw and code as vars print raw p.s. why I want to do this: when you're in class method, it's damned hard to have 6 manipulation with strings in join() and format() when string is self.data['raw']['code'] (assume it's dict in dict

How to extract values from rasterstack with xy coordinates?

风格不统一 提交于 2019-11-27 22:29:21
I have a rasterstack (5 raster layers) that actually is a time series raster. r <- raster(nrow=20, ncol=200) s <- stack( sapply(1:5, function(i) setValues(r, rnorm(ncell(r), i, 3) )) ) s class : RasterStack dimensions : 20, 200, 4000, 5 (nrow, ncol, ncell, nlayers) resolution : 1.8, 9 (x, y) extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 names : layer.1, layer.2, layer.3, layer.4, layer.5 min values : -9.012146, -9.165947, -9.707269, -7.829763, -5.332007 max values : 11.32811, 11.97328, 15.99459, 15.66769, 16.72236 My