extract

How to extract the keys and values of an array without index [closed]

只愿长相守 提交于 2019-12-01 03:29:47
I want to extract data from an array (original array with key and value). After I extract the array, I want two new arrays, the first one with just the keys, the second one with just the values, and both without indexes (see code example). // original array $array = array( "name1"=>500 ,"name2"=>400 ,"name3"=>300 ,"name4"=>200 ,"name5"=>100 ); // after extraction $array1 = array('name1','name2','name3','name4','name5'); $array2 = array(500,400,300,200,100); // not like this // $array1 = array(0=>'name1',1=>'name2',2=>'name3',3=>'name4',4=>'name5); // $array2 = array(0=>500,1=>400,2=?300,3=>200

Extract a .tar.gz file in java (JSP)

心已入冬 提交于 2019-12-01 03:29:13
问题 I can't seem to import the packages needed or find any online examples of how to extract a .tar.gz file in java. What makes it worse is I'm using JSP pages and am having trouble importing packages into my project. I'm copying the .jar's into WebContent/WEB-INF/lib/ and then right clicking on the project and selecting import external jar and importing it. Sometimes the packages resolve, other times they don't. Can't seem to get GZIP to import either. The imports in eclipse for jsp aren't

How to extract the first and final words from a string?

耗尽温柔 提交于 2019-12-01 02:27:57
I have a small problem with something I need to do in school... My task is the get a raw input string from a user ( text = raw_input() ) and I need to print the first and final words of that string. Can someone help me with that? I have been looking for an answer all day... You have to firstly convert the string to list of words using str.split and then you may access it like: >>> my_str = "Hello SO user, How are you" >>> word_list = my_str.split() # list of words # first word v v last word >>> word_list[0], word_list[-1] ('Hello', 'you') From Python 3.x , you may simply do: >>> first, *middle

JSoup - Select all comments

自闭症网瘾萝莉.ら 提交于 2019-12-01 01:31:49
I want to select all comments from a document using JSoup. I would like to do something like this: for(Element e : doc.select("comment")) { System.out.println(e); } I have tried this: for (Element e : doc.getAllElements()) { if (e instanceof Comment) { } } But the following error occurs in eclipse "Incompatible conditional operand types Element and Comment". Cheers, Pete Since Comment extends Node you need to apply instanceof to the node objects, not the elements, like this: for(Element e : doc.getAllElements()){ for(Node n: e.childNodes()){ if(n instanceof Comment){ System.out.println(n); } }

extract hour from timestamp with python

孤人 提交于 2019-12-01 01:24:57
问题 I have a dataframe df_energy2 df_energy2.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 29974 entries, 0 to 29973 Data columns (total 4 columns): TIMESTAMP 29974 non-null datetime64[ns] P_ACT_KW 29974 non-null int64 PERIODE_TARIF 29974 non-null object P_SOUSCR 29974 non-null int64 dtypes: datetime64[ns](1), int64(2), object(1) memory usage: 936.8+ KB with this structure : df_energy2.head() TIMESTAMP P_ACT_KW PERIODE_TARIF P_SOUSCR 2016-01-01 00:00:00 116 HC 250 2016-01-01 00:10:00

How to extract specific columns from a space separated file in Python?

无人久伴 提交于 2019-12-01 01:15:43
I'm trying to process a file from the protein data bank which is separated by spaces (not \t). I have a .txt file and I want to extract specific rows and, from that rows, I want to extract only a few columns. I need to do it in Python. I tried first with command line and used awk command with no problem, but I have no idea of how to do the same in Python. Here is an extract of my file: [...] SEQRES 6 B 80 ALA LEU SER ILE LYS LYS ALA GLN THR PRO GLN GLN TRP SEQRES 7 B 80 LYS PRO HELIX 1 1 THR A 68 SER A 81 1 14 HELIX 2 2 CYS A 97 LEU A 110 1 14 HELIX 3 3 ASN A 122 SER A 133 1 12 [...] For

Add files to exe and then extract them

跟風遠走 提交于 2019-12-01 01:12:59
i am making a windows installer , i need to put some files in my program and then extract them to some folder when program runs , lets say i am going to put 3 files in single exe file . thanks a lot for your help in advance , love ya Stackoverflow members :) Have a read here : http://support.microsoft.com/kb/319292 This shows how to extract the resource into a Stream, you can then write this stream to disk. There exist two options: (1) add files as resources, and (2) append the whole package with files to the end of your EXE and mark it in some way (with magic numbers) and then open EXE for

Bash script to extract entries from log file based on dates specified in another file?

房东的猫 提交于 2019-12-01 00:41:10
I've got a pretty big comma-delimited CSV log file (>50000 rows, let's call it file1.csv) that looks something like this: field1,field2,MM-DD-YY HH:MM:SS,field4,field5... ... field1,field2,07-29-10 08:04:22.7,field4,field5... field1,field2,07-29-10 08:04:24.7,field4,field5... field1,field2,07-29-10 08:04:26.7,field4,field5... field1,field2,07-29-10 08:04:28.7,field4,field5... field1,field2,07-29-10 08:04:30.7,field4,field5... ... As you can see, there is a field in the middle that is a time stamp. I also have a file (let's call it file2.csv) that has a short list of times: timestamp,YYYY,MM,DD

How to extract the keys and values of an array without index [closed]

旧时模样 提交于 2019-11-30 23:25:29
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I want to extract data from an array (original array with key and value). After I extract the array, I want two new arrays, the first one with just the keys, the second one with just the values, and both without

Java - Regex extract date from string

痴心易碎 提交于 2019-11-30 23:11:01
I need to extract date from this string: BB inform: buy your tickect, final card number xxxx, $ 00,00, on 04/10, at 11:28. If you don't recognize call 40032 2412. Also The full date 04/10/2015 The date pattern is dd/MM or dd/MM/yyyy The code: String mydata = "BB inform: buy your tickect, final card number xxxx, $ 00,00, on 04/10, at 11:28. If you don't recognize call 40032 2412."; Pattern p = Pattern.compile("(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d"); Matcher m = p.matcher(mydata); Result: m.matches() == false You can try with this regex : Matcher m = Pattern.compile("