w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Commas do not echo with line
Try something like this (though it would help if you can provide sample input): while IFS=, read -ra line; do if [ "${line[1]}" != "" ] then (IFS=, ; line="${line[*]}"; echo -n "$line, Hash Value: ") && echo "${line[1]}" | openssl dgst -sha1 | sed 's/^.* //' else break fi done

Categories : Arrays

Find line that does not end in 83 consecutive commas
The problem with [^,]{83} is that it requires there to be 83 characters which at the same time none are commas. So if any of the last 83 characters are a comma then that expression will fail. It would be easier to use a negative lookahead to search for the bad thing and and fail if is found. ^(?!.*,{83}$)

Categories : Regex

Regex: How to grab strings within quotes, commas, spaces, and new line?
You can simply split, trim and remove the quotes: var list = str.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries) .Select(x => x.Trim().Replace(""", ""));

Categories : C#

Getting all array entries that contains certain string, that is next to each other, and the line before the first
Here's one possible approach: create two patterns, one for the 'Showing...' message and other for 'Displaying' message; iterate over your array in a reverse order (from the end to the beginning), checking each string if the string matches 'Showing pattern', check each consequent string for 'Displaying' pattern match; if it does, place it into some container. The matched string should be probably placed into this container too. And here's one possible implementation: $datePattern = 'd{4}-d{2}-d{2}'; $timePattern = 'd{2}:d{2}:d{2}'; $headerPattern = $datePattern . ' ' . $timePattern . ' [INFO] '; $showingPattern = $headerPattern . 'Showing d+ objective(s) on scoreboard'; $messagePattern = $headerPattern . "- [^:]+: displays as '[^']*' and is type '[^']*'"; $results = array();

Categories : PHP

SQL: Get multiple line entries linked to one item?
simple one: select "ITEMID", case when min("STATUS") in (4, 5) and max("STATUS") in (4, 5) then 'True' else 'False' end as requirements_met from table1 group by "ITEMID" better one: select "ITEMID", sum(case when "STATUS" in (4, 5) then 1 else 0 end) as MET_REQUIREMENTS, sum(case when "STATUS" in (4, 5) then 0 else 1 end) as NOT_MET_REQUIREMENTS from table1 group by "ITEMID"; sql fiddle demo

Categories : SQL

Python program to remove double entries from line
Use set line = line.split() line = list(set(line)) set returns an un-ordered collection of unique elements, then convert it back to list and then sort the list. Edit: line = line.split() line = list(set(line)) out.write(" ".join(sorted(line, x: (int(x.split(':')[0]), int(x.split(':')[1])))) + ' ')

Categories : Python

Python: How to check an XML file every x minutes for new entries, but not alert on previously alerted entries
Are the entries associated with a timestamp such that the new entries will always have timestamps later than the old entries each time the file is updated? If so, just keep the timestamp of the last entry you pushed, and as you parse the XML file, push anything newer and discard anything older. If not, Python has pretty decent set manipulation algorithms, so I'd try this: keep a set of entries that have been pushed already. already_pushed = set() Each time your script runs, do this: make another set of the entries from the file from_file = parse_file() "subtract" (set difference) the set of already-pushed entries new_entries = from_file - already_pushed push the new entries push_all(new_entries) go through the original set and prune anything older than 4 hours + 5 minutes cuto

Categories : Python

Unique entries for normal entries?
The DDL command to add a unique constraint on multiple columns: ALTER TABLE `table_name` ADD UNIQUE INDEX (`column1`, `column2`);

Categories : Mysql

How to smooth datatable of 15 entries to 100 entries?
A possible solution for 106 values: int k = 0; double a; double b; double[] coarse; double[] fine; for (int i = 0; i < 15; i++) for (int j = 0; j < 7; j++) { a = 1.0 - j * 1.0/7; b = 1.0 - a; fine[k++] = a * coarse[i] + b * coarse[i+1]; } fine[k] = coarse[14]; This assumes that the 15 original values are stored in array coarse[]. The interpolated values will end in array fine[].

Categories : C#

Select table entries belonging to combinations of entries in another table (mysql)
I assume you have two table: orders (list of your orders) order_items (list of itemd of order) two table are relationed by field fk_order. try this: SELECT o.id, (select count(*) from order_items i where i.status = 'delivered' and i.fk_order = o.id) as item_delivered, (select count(distinct i.status) from order_items i where i.fk_order = o.id) as status_no FROM orders o

Categories : Mysql

Registry keys for context menu entries written, but no context menu entries
Most likely, the people whom it didn't work for have had .gif and/or .jpg associated with a different ProgId than "giffile" or "jpegfile". You can get Inno to add the registration to whatever the current ProgId association is like so: [Registry] Root: HKLM; Subkey: "SOFTWAREClasses{reg:HKLMSOFTWAREClasses.jpg|jpegfile}shellHalve size"; Flags: uninsdeletekey Root: HKLM; Subkey: "SOFTWAREClasses{reg:HKLMSOFTWAREClasses.jpg|jpegfile}shellHalve sizecommand"; ValueType: string; ValueName: ""; ValueData: """{app}himgr.exe"" ""%1""" Root: HKLM; Subkey: "SOFTWAREclasses{reg:HKLMSOFTWAREClasses.png|pngfile}shellHalve size"; Flags: uninsdeletekey Root: HKLM; Subkey: "SOFTWAREclasses{reg:HKLMSOFTWAREClasses.png|pngfile}shellHalve sizecommand"; ValueType: string; ValueName: ""; ValueData: """{app}hi

Categories : C#

How to output commas in CSV
You need to wrap the entry in a quote temp.Append(""ab,cd,ed""); UPDATED AFTER REDITED QUESTION From what you are saying you wish to convert 123,445,567,890 to 123,445,567.890 and you want to the CSV output to work: You still need to wrap your result in quotes so you need amt = string.Format(""{0}.{1}"", match.Groups[1].Value, match.Groups[2].Value); Alternatively you could just replace the last ',' amt = new Regex(",(?=\d{3}"$)").Replace(x,"."); or without the regex. char[] y = amt.ToCharArray(); y[amt.LastIndexOf(",")] = '.'; amt = string(y);

Categories : C#

Jquery removing commas
What about this? var opt3=$('#opt1').val().replace(",",""); Update: Ok. Like @jreziga mentioned. The return value of .val() will be an array. If you have a string the upper code example will do just fine. If you have an array like in your case you can do this: var opt3=$('#opt1').val().join("");

Categories : PHP

How do I add commas in data values
Use Array.map(), it will create a new list from another with some conditions you want. var arr = [230570, 231055, 231055, 232325, 232914, 241636, 241748, 241748, 242330, 242633], parsed = arr.map(function(element, index, array) { var string = element.toString(), part1 = string.substring(0, 3), part2 = string.substring(3); return part1 + "," + part2; }); alert(parsed); Since it is not fully supported you can also do this with a for loop, define element as arr[i] and you're done! var arr = [230570, 231055, 231055, 232325, 232914, 241636, 241748, 241748, 242330, 242633], parsed = []; for(var i = 0; i < arr.length; i++) { var string = arr[i].toString(); part1 = string.substring(0, 3), part2 = string.substring(3);

Categories : Javascript

How to have Android automatically add commas?
Ok. I tested a bit around and I got the solution. String in = "123456789"; double amount = Double.parseDouble(in); amount = amount / 10; DecimalFormat df = new DecimalFormat(".00"); String formatted = df.format(amount); System.out.println(formatted); ==>> output is here: 12345678,90 you have to divide your double to get your comma. The double you get with your version is 123456789.00 --> by dividing it by 10 .. or whatever you like it gets 12345678.90 ... in that case a simple String.valueOf(amount); would be sufficient. But if you change the DecimalFormat to DecimalFormat df = new DecimalFormat(",###.00"); your output is ==> 12.345.678,90

Categories : Java

Encoding only spaces and commas in URL
You should use CGI.escape. Don't use it for the entire URL, but only for the values of it. require "cgi" "http://URL?" + params.map{|k, v| "#{k}=#{CGI.escape(v)}"}.join("&")

Categories : Ruby On Rails

how can I handle values which have commas in csv?
You probably need to look int the setEscapeMode method on CSVReader. Something like reader.setEscapeMode(CsvReader.ESCAPE_MODE_BACKSLASH) ought to set the reader so that it regards a backslash as an escape.

Categories : Java

How to strip commas from float input?
Removing commas is pretty simple: value.gsub(/,/, '').to_f Keep in mind that European formatting often uses comma as the decimal value separator so your results would be off by a factor of 100 if processing those sorts of numbers.

Categories : Ruby On Rails

Unpacking? strange commas in python
Essentially, the tuple (m1,m2) is recieving the values in the tuple (x,m1). After the statement m1 will have the old value of x and m2 will have the old value of m1. Example: >>> x = 2 >>> y = 3 >>> z = 4 >>> x,y = y,z >>> x 3 >>> y 4 The tuple (x,m1) is created before any assignments are made. As a result, this syntax is often used for swapping two variables. For example, x,y = y,x will swap the values in x and y.

Categories : Python

Adding commas when echoing an array
Try this <form method="post"> <?PHP include("config.php"); $data = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC"); while ($info = mysql_fetch_array($data)) { $id = addslashes($info['id']); echo "<input type="checkbox" value="$id" name="delete[]"><b>" .$info['name']. ": </b>" .$info['shout']."<br>"; }//END WHILE LOOP if (isset($_POST['delete'])) { $idList = "'" . mysql_real_escape_string(implode("','", $_POST['delete'])) . "'"; mysql_query("DELETE * FROM shoutbox WHERE id IN (" . $idList . ") "); echo $idList; }//END IF ?> <input type="submit" /> </form>

Categories : PHP

Put words, separated by commas, in quotes
Try: for l in range( 1, line('$') ) | call append( line('.') - 1, join( map( split( getline('.'), ',' ), '""" . v:val . """' ), ',' ) ) | delete | endfor Explanation: For each line split line with comma, add a leading and trailing double quote using map function, join them with comma and append it above current line, and then delete current cursor line, that will be the old one.

Categories : Vim

How to remove commas in a SQL output to print in a CSV?
You can use fputcsv to get properly escaped csv. $fp = fopen("php://output", "w"); foreach($result as $row) { fputcsv($fp, (array) $row)); } fclose($fp); drupal_exit();

Categories : PHP

How To Get Twitter Followes_Count To echo with commas
It would work with that: <?php $data = json_decode(file_get_contents('https://api.twitter.com/1/users/lookup.json?screen_name=erinschreyer'), true); $followers = $data[0]['followers_count']; echo number_format($followers); ?> See number_format()

Categories : Twitter

Addressing both commas and double quotes in a CSV
I was able to finally solve this after A LOT of searching and testing. In order to fix this, I simply replaced each double-quote with two double-quotes. Having two double-quotes treats the double-quote as an 'escape value'... which I guess means that the double-quote is not treated like a closed quote. This might be a SQR specific solution. Simplified code solution: Let $asset_descr = '"' || Replace(&dep_asset.descr, '"', '""') || '"' Let $string = $asset_descr Write 1 from $string

Categories : Csv

replacing commas with slashes in JavaScript
document.getElementById('val') should be document.getElementById('one') If you make this change you don't need to send this to removeComma. If you keep this then use the following function function removeComma(val) { var values = val.value; var n=values.replace(/,/, "/"); val.value=n; }

Categories : Javascript

Python add commas to integers recursively
Think, if you have 12345 and you know the the format for 12, then how will you compute for 12345 ? def comma(n): if not isinstance(n,str): n = str(n) if len(n) < 4: return n else: return comma(n[:-3]) + ',' + n[-3:]

Categories : Python

Regex for prices, skipping over commas
you can use this pattern instead: $d{1,3}(?:,?d{3})*(?:.d{2})? note that i have supposed that you have always two digits after the period. You can easily change this if you need.

Categories : Regex

C++ CSV Parsing with Commas Inside of Quotes
There is no formal standard for CSV format, but let's note at the outset that the ugly column you have cited: "abc, defghijk. "Lmnopqrs, "tuv,"" wxyz.", does not conform to what are deemed to be the Basic Rules of CSV, because two of those are:- 1) Fields with embedded commas must be quoted. 2) Each of the embedded double-quote characters must be represented by a pair of double-quote characters. If the problem column obeys rule 1) then it doesn't obey rule 2). But we can construe it so as to obey rule 1) - so we can say where it ends - if we balance the double-quotes as, e.g. [abc, defghijk. [Lmnopqrs, ]tuv,[] wxyz.], The balanced outermost quotes enclose the column. The balanced internal quotes can just lack any other indication of being internal except that the balancing makes

Categories : C++

Why are commas not working as expected in a XSL nested for-each?
Your originally posted transform works on my XSL transformer. I think your problem may be with the transformer itself. I just copied and pasted your XML and XSL and got the desired output from XSLT.

Categories : Json

How to remove unwanted commas from a string?
Try this: $str = preg_replace('/,{2,}/', ',', trim($str, ',')); The trim will remove starting and trailing commas, while the preg_replace will remove duplicate ones. See it in action! Also, as @Spudley suggested, the regex /,{2,}/ could be replaced with /,,+/ and it would work too. EDIT: If there are spaces between commas, you may try adding the following line after the one above: $str = implode(',', array_map('trim', explode(',', $str)))

Categories : PHP

How to stream input line by line in UNIX, perform commands on each line, and immediately return output?
You can use echo "${#line}" to know the length of a string. Reading the file with a while read... will do the rest: $ cat file hello my name is fedor qui $ while read line; do echo "${#line}"; done < file 5 7 8 3 0 In a nicer format: while read line do echo "${#line}" done < file

Categories : Shell

Writing csv file in Python: unwanted commas appear
You are looping over the characters in the line instead of the actual elements with open(file_, 'r') as source, open(output, 'w') as outp: data = csv.reader(source, delimiter=deli) #line0 = next(data) i = 0 for element in data: dictionary[i] = element i += 1 also it's considered to be good practice to not override the built-ins in this case you are overriding file, instead PEP 008 recommends that you add an underscore to the end of you variable name.

Categories : Python

Selectively deleting commas and splitting strings
A silly (but functional) answer: inquotes=false; keep=true(1,length(txt)); for v=1:length(txt) if (txt(v)=='"') inquotes=~inquotes; elseif (txt(v)==',' && inquotes) keep(v)=false; end end txt=txt(keep); tt=strsplit(txt,','); This will, if you are in quotes, remove the commas so that you can use strsplit. That is what I understood you want to do, correct?

Categories : Regex

How to insert commas in numbers in an html template?
There are many ways: You can wrap your money values inside a <span class='money'></span> span, and then using jQuery format those values, on DOM ready. Using Angular JS, you can give your money values a directive, say ng-money and define that directive such that it formats the content of that span. Third way is to send money values already commified (as you mentioned that :D ), and use them directly inside your template. Usually on server side, it's easier to format numbers and values.

Categories : Javascript

Only strip commas surrounded by numbers in a string
It sounds like you want to use a regular expression: string rawtext = Regex.Replace(nextLine, @"(d),(d)", "$1$2"); Or this equivalent pattern: string rawtext = Regex.Replace(input, @"(?<=d),(?=d)", "");

Categories : C#

Regex to find commas within quoted elems of csv
After a quick google: ^(("(?:[^"]|"")*"|[^,]*)(,("(?:[^"]|"")*"|[^,]*))*)$ This matches single elements in line of the csv file. http://www.kimgentes.com/worshiptech-web-tools-page/2008/10/14/regex-pattern-for-parsing-csv-files-with-embedded-commas-dou.html

Categories : Java

How to have Android automatically add commas in large numbers?
You can use DecimalFormat as it even supports locales (some places use . instead of ,) String number = "1000500000.574"; double amount = Double.parseDouble(number); DecimalFormat formatter = new DecimalFormat("#,###.00"); String formatted = formatter.format(amount);

Categories : Android

Use jquery or javascript to add commas to disabled field
May be you might want to trigger change event manually through javascript for your three read-only input fields. Using jquery trigger . I am not sure but it seems like a bad idea to have a read-only input field if no user can change these values. Usually having read-only input fields is good if a user with some security can edit those and some cannot.

Categories : Javascript

Replace returns with spaces and commas with semicolons?
You don't need to quote in your search and replace, only to represent a space in your first example (or you could just do / / too). $str =~ s/ /" "/g; $str =~ s/,/;/g;

Categories : Perl

Converting data with commas to variables in JavaScript
Is this what you want? // the string containing the data var externalData = 'one, two, three ' + 'four, five, six ' + 'seven, eight, nine'; // split the string into rows, and split each row into cells var parsed = externalData.split(' ').map(function(row) { return row.split(', '); }); console.log(parsed[0][1]); // 'two'

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.