extract

How to use jq to find all paths to a certain key

北慕城南 提交于 2019-11-30 20:19:31
In a very large nested json structure I'm trying to find all of the paths that end in a key. ex: { "A": { "A1": { "foo": { "_": "_" } }, "A2": { "_": "_" } }, "B": { "B1": {} }, "foo": { "_": "_" } } would print something along the lines of: ["A","A1","foo"], ["foo"] Unfortunately I don't know at what level of nesting the keys will appear, so I haven't been able to figure it out with a simple select. I've gotten close with jq '[paths] | .[] | select(contains(["foo"]))' , but the output contains all the permutations of any tree that contains foo. output: ["A", "A1", "foo"]["A", "A1", "foo", "_"

How to Extract docx (Word 2007 above) using Apache POI

百般思念 提交于 2019-11-30 17:51:19
问题 Hai, i'm using Apache POI 3.6 I've already created some code.. XWPFDocument doc = new XWPFDocument(new FileInputStream(file)); wordxExtractor = new XWPFWordExtractor(doc); text = wordxExtractor.getText(); System.out.println("adding docx " + file); d.add(new Field("content", text, Field.Store.NO, Field.Index.ANALYZED)); unfortunately, it generated error.. Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException at org.apache.poi.openxml4j.opc.OPCPackage.init

Extract time series of a point ( lon, lat) from netCDF in R

社会主义新天地 提交于 2019-11-30 17:01:35
问题 I am relatively new on R. I am trying to get time series of different points ( lat, lon) of temperature data from a netCDF file. My sample data file is here and here is the small file . I have tried netCDF package and the code i have used so far library(ncdf) obsdata = open.ncdf("obs.nc") print.ncdf(obsdata) obsdatadates = obsdata$dim$time$vals obsdatadates = as.Date(obsdatadates,origin = '1950-01-01') obsdatadates obsoutput = get.var.ncdf(obsdata, varid = 'tasmin', start = c(1,1,1), count =

How to extract audio from a video file using python?

拈花ヽ惹草 提交于 2019-11-30 17:00:38
问题 I want to write a python program that could extract audio from a video file (e.g. video.avi ). Is there any good library for it? And where should I start from? I tried to use PyMedia, but I couldn't install it on my MacOSX(Mountain Lion). EDIT: The problem is video.avi is not completely available. Someone is writing on it and adding some frames to it every second. So I wanted to write a code in python to get the video as it comes and extract the audio from it and write it to a file (e.g.

download a zip file to a local drive and extract all files to a destination folder using python 2.5

血红的双手。 提交于 2019-11-30 16:14:31
I am trying to download a zip file to a local drive and extract all files to a destination folder. so i have come up with solution but it is only to "download" a file from a directory to another directory but it doesn't work for downloading files. for the extraction, I am able to get it to work in 2.6 but not for 2.5. so any suggestions for the work around or another approach I am definitely open to. thanks in advance. ###################################### '''this part works but it is not good for URl links''' import shutil sourceFile = r"C:\Users\blueman\master\test2.5.zip" destDir = r"C:

Removing text enclosed between HTML tags using JSoup

允我心安 提交于 2019-11-30 15:31:08
In some cases of HTML cleaning, I would like to retain the text enclosed between the tags(which is the default behaviour of Jsoup) and in some cases, I would like to remove the text as well as the HTML tags. Can someone please throw some light on how I can remove the text enclosed between the HTML tags using Jsoup? The Cleaner will always drop tags and preserve text. If you need to drop elements (i.e. tags and text / nested elements), you can pre-parse the HTML, remove the elements using either remove() or empty() , then run the resulting through the cleaner. For example: String html = "Clean

How do I get a youtube video ID (PHP) [closed]

时光总嘲笑我的痴心妄想 提交于 2019-11-30 15:21:34
Given a link from youtube e.g. http://www.youtube.com/watch?v=XHs99iVpnXU how do I extract the video id (the v parameter) without it being affected by other parameters such as feature= e.g. http://www.youtube.com/watch?v=XHs99iVpnXU&feature=watch&fullscrenn=true ? parse_str(parse_url($url, PHP_URL_QUERY), $variables) print $variables['v']; 来源: https://stackoverflow.com/questions/9522868/how-do-i-get-a-youtube-video-id-php

Using java to extract .rar files

泄露秘密 提交于 2019-11-30 14:49:02
问题 I am looking a ways to unzip .rar files using Java and where ever I search i keep ending up with the same tool - JavaUnRar . I have been looking into unzipping .rar files with this but all the ways i seem to find to do this are very long and awkward like in this example I am currently able to extract .tar , .tar.gz , .zip and .jar files in 20 lines of code or less so there must be a simpler way to extract .rar files, does anybody know? Just if it helps anybody this is the code that I am using

Delphi: open a zip archive from a stream -> extract to a stream

﹥>﹥吖頭↗ 提交于 2019-11-30 14:00:57
Are there any zip components with such features? I need to download a zip archive from the Internet to a stream, then to open the archive from the stream and then to extract files to another stream. E.g. ZipForge can open an archive from a stream ZipForge.OpenArchive(MyStream, false); but how to extract to another one...? procedure ExtractToStream(FileName: WideString; Stream: TStream); Description Use ExtractToStream to decompress data stored in the file inside the archive to a TStream descendant object like TFileStream, TMemoryStream or TBlobStream. The FileName parameter specifies file name

How to extract Raw of TCP packet using Scapy

混江龙づ霸主 提交于 2019-11-30 13:52:47
I use the sniff function of scapy module. My filter and prn function are doing a great job. But now, I would like to extract the Raw of the TCP packet and handle it using hexadecimal or binary format. Here is the documentation of Packet Class in scapy. How can I do that ? I tried print packet[Raw] but it seems to be converted as ASCII or something like that. I want to keep it in hexadecimal or binary. You can get the raw bytes of the packet via str(packet) . For printing them to the screen in a readable format you can execute print str(packet).encode("HEX") . 来源: https://stackoverflow.com