separator

Maintaining the separator in awk output

不羁的心 提交于 2019-12-12 02:54:10
问题 I would like to subset a file while I keep the separator in the subsetted output using ´awk´ in bash. That´s what I am using: The input file is created in R language with: inp <- 'AX-1 1 125 AA 0.2 1 AB -0.89 0 AA 0.005 0.56 AX-2 2 456 AA 0 0 AA -0.56 0.56 AB -0.003 0 AX-3 3 3445 BB 1.2 1 NA 0.002 0 AA 0.005 0.55' inp <- read.table(text=inp, header=F) write.table(inp, "inp.txt", col.names=F, row.names=F, quote=F, sep="\t") (So fields are separated by tabs) The code in bash: awk {'print $1 $2

Separating Numeric values from Text Values

时间秒杀一切 提交于 2019-12-11 22:19:51
问题 I am retrieving information from a REST API and it displays: "Per 78g - Calories: 221kcal | Fat: 12.65g | Carbs: 16.20g | Protein: 10.88g" I have imported the items into a ListView and when a user clicks an item I would like to string each numeric value individually like below without their text. Based on the example above: String calories = 221; String fat = 12.65; String carbs = 16.20; String protein = 10.88; I got rid of the "Per 78g" with: String sd = food.getString("food_description");

HTML::TableExtract: how to run the right argument [see live example]

六月ゝ 毕业季﹏ 提交于 2019-12-11 12:32:10
问题 A question regarding a parser. Is there any chance to catch some separators within the that separate the table... The paser script runs allready nicely. Note - i want to store the data into a MySQL database. So it would be great to have some seperators - (commas, tabs or somewhat else - a tab seperated values or comma seperated values are handy formats to work with... ( here the data out of the following site: http://192.68.214.70/km/asps/schulsuche.asp?q=a&a=20 ) lfd. Nr. Schul- nummer

what is the point of using DIRECTORY_SEPARATOR over “/” in php

混江龙づ霸主 提交于 2019-12-11 08:52:00
问题 Why would I choose to use . DIRECTORY_SEPARATOR . instead of . "/" . ? My initial thought was that there could be a different separator instead of a slash, but if I'm designing, say, a Wordpress Plugin, can I not assume that there is always a / separating two folders? 回答1: If the application is going to run on a variety of operating systems then the directory won't always be a forward slash. It's a backwards slash on Windows for example. A similar case is new lines. It's \n on *nix, \r\n on

Comma Separate Number Without stringstream

时光总嘲笑我的痴心妄想 提交于 2019-12-11 07:33:15
问题 So typically if I wanted to insert locale appropriate separators in some number, foo , I'd do something like this: ostringstream out; out.imbue(locale("en-US")); out << foo; Then I could just use out.str() as the separated string: http://coliru.stacked-crooked.com/a/054e927de25b5ad0 Unfortunately I've been asked not to use stringstreams in my current project. Is there any other way I can accomplish this? Ideally a locale dependent way? 回答1: So this answer is the C++ distillation of Jerry

Hadoop - output key/value separator

眉间皱痕 提交于 2019-12-11 03:33:12
问题 I want to change the Output Separator to ; instead of tab. I already tried: Hadoop: key and value are tab separated in the output file. how to do it semicolon-separated? but still my Output ist key (tab) value I'm using the Cloudera Demo (CDH 4.1.3). Here is my Code: Configuration conf = new Configuration(); String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); if (otherArgs.length != 2) { System.err.println("Usage: Driver <in> <out>"); System.exit(2); } conf.set(

regex split string with two separators

坚强是说给别人听的谎言 提交于 2019-12-11 02:43:04
问题 Using JavaScript, Is there a way to split the string to an array with two separators: ':' and ',' For var str = "21:223, 310:320"; would like the Result to be: [21, 223, 310, 320]; Thanks! 回答1: You could use a regular expression which looks for a : or for a comma with an optional space , . console.log("21:223, 310:320,42".split(/:|, */)); 回答2: You can use match if your expression is like this "21:223, 310:320" var str = "21 : 223 , 310 : 320 "; //---------^^----^^^---^^^----^^^-- // group of

Split list by tuple separator

可紊 提交于 2019-12-11 02:13:27
问题 I have list: print (L) [('I', 'WW'), ('am', 'XX'), ('newbie', 'YY'), ('.', 'ZZ'), ('You', 'WW'), ('are', 'XX'), ('cool', 'YY'), ('.', 'ZZ')] I want split list to sublists with separator ('.', 'ZZ') : print (new_L) [[('I', 'WW'), ('am', 'XX'), ('newbie', 'YY'), ('.', 'ZZ')], [('You', 'WW'), ('are', 'XX'), ('cool', 'YY'), ('.', 'ZZ')]] I am interested about another possible solutions, performance is important. 回答1: The for-loop approach will be faster, this requires only one-pass: >>> def juan

Reading csv with separator in python dask

浪子不回头ぞ 提交于 2019-12-11 01:33:08
问题 I am trying to create a DataFrame by reading a csv file separated by '#####' 5 hashes The code is: import dask.dataframe as dd df = dd.read_csv('D:\temp.csv',sep='#####',engine='python') res = df.compute() Error is: dask.async.ValueError: Dask dataframe inspected the first 1,000 rows of your csv file to guess the data types of your columns. These first 1,000 rows led us to an incorrect guess. For example a column may have had integers in the first 1000 rows followed by a float or missing

Insert char to string to end of number

限于喜欢 提交于 2019-12-11 00:05:35
问题 I have ugly string: oldstr = "0.100% fDrg: 2%,dgdv: 29% fGd dg 0.2%, Ghh-sf 2.2 dbgh: NONE dfgdf6 gd 3 " I need to insert char | after the last digit of number for next splitting by this inserted | . There is also value none , where is also added this separator: 0.100| fdrg: 2|,dgdv: 29| fgd dg 0.2|, ghh-sf 2.2|dbgh: none| dfgdf6|gd 3| I try this, but no success: print re.sub(r'(\d+[a-z %^.])', r'\1|', oldstr.lower()) 0.|100%| fdrg: 2%|,dgdv: 29%| fgd dg 0.|2%|, ghh-sf 2.|2 |dbgh: none dfgdf6