w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Converting Character to Numeric without NA Coercion in R
As Anando pointed out, the problem is somewhere in your data, and we can't really help you much without a reproducible example. That said, here's a code snippet to help you pin down the records in your data that are causing you problems: test = as.character(c(1,2,3,4,'M')) v = as.numeric(test) # NAs intorduced by coercion ix.na = is.na(v) which(ix.na) # row index of our problem = 5 test[ix.na] # shows the problematic record, "M" Instead of guessing as to why NAs are being introduced, pull out the records that are causing the problem and address them directly/individually until the NAs go away. UPDATE: Looks like the problem is in your call to str_replace_all. I don't know the stringr library, but I think you can accomplish the same thing with gsub like this: v2 = c("1.00","2.00","3.0

Categories : R

SQL server 2008 R2 Arithmetic overflow error converting numeric to data type numeric
The NUMERIC_ROUNDABORT option is ON When SET NUMERIC_ROUNDABORT is ON, an error is generated after a loss of precision occurs in an expression. When OFF, losses of precision do not generate error messages and the result is rounded to the precision of the column or variable storing the result. Normally this is OFF because when ON indexed views etc can fail. I've never changed this, ever. SET NOCOUNT ON; GO PRINT 'ON' set NUMERIC_ROUNDABORT ON; select cast(cast(1.260 as numeric(13,3)) as numeric(10,2)); GO PRINT 'OFF' set NUMERIC_ROUNDABORT OFF; select cast(cast(1.260 as numeric(13,3)) as numeric(10,2)); GO gives ON --------------------------------------- Msg 8115, Level 16, State 7, Line 3 Arithmetic overflow error converting numeric to data type numeric. OFF -----------------

Categories : Sql Server

ORA-01858: a non-numeric character was found where a numeric was expected
The answer is really simple here: In your command, build the following string TO_DATE(:1, 'yyyy-mm-dd') . Then, just make sure that string that goes into :1 has accurate format. Your command text should be this: SELECT * FROM (SELECT DocumentId FROM idx1_AuthLetters a INNER JOIN Documents b ON a.DocumentId = b.Id WHERE Status in ('L','S','V') AND letter_date <= TO_DATE(:1, 'yyyy-mm-dd') ORDER BY DOCUMENTID ) WHERE RowNum <= 14

Categories : C#

webgrid sort ipaddress based on numeric representation
So I've got a workaround, its not the best but it works. I convert the IP address form the four octets stored in the database to the decimal representation, pass that to the webgrid so it can sort the value properly then provide a custom formatting function to take the decimal value and convert it back to dotted decimal form. The code I used to do this is here: https://gist.github.com/TechplexEngineer/5951594

Categories : Asp Net Mvc

How to replace space/character with specified character after first numeric value in string using C#?
var match = Regex.Match(text, search); //To search for any special character, use @"W" as the second parameter var editable = text.ToCharArray(); editable[match.Index] = replace[0]; text = new String(editable); return text;

Categories : C#

Having error, Arithmetic overflow error converting numeric to data type numeric
Am column defined as decimal(n,m) holds n decimal digits, m of which are the fraction part. So decimal(2,2) is 2 digits long, both of which are the fraction part. This will only be able to take values in the range -0.99 to 0.99.

Categories : Sql Server

Converting String to UTF-16 Representation in Java
public class UseTheForce { public static void main(final String[] args) throws java.io.UnsupportedEncodingException { for (final byte b : args[0].getBytes(args[1])) { System.out.printf("%1$02X ", (b & 0xFF)); } System.out.println(); } } Test $ java UseTheForce luke US-ASCII 6C 75 6B 65 $ java UseTheForce luke UTF-8 6C 75 6B 65 $ java UseTheForce luke UTF-16 FE FF 00 6C 00 75 00 6B 00 65 $ java UseTheForce luke UTF-16BE 00 6C 00 75 00 6B 00 65 $ java UseTheForce luke UTF-16LE 6C 00 75 00 6B 00 65 00 $ java UseTheForce luke UTF-32 00 00 00 6C 00 00 00 75 00 00 00 6B 00 00 00 65 May the force be with you.

Categories : Java

When using late-bound enumerated type is the only option to use the numeric representation of the type
Put this in the declarations section of a standard module Enum adCommandTypeEnum adCmdUnspecified = -1 adCmdText = 1 adCmdTable = 2 adCmdStoredProc = 4 adCmdUnknown = 8 adCmdFile = 256 adCmdTableDirect = 512 End Enum And it will work just like if you early bound. If you go back to early binding, make sure you delete this. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675946%28v=vs.85%29.aspx

Categories : Vba

Converting the name of a character (i.e. comma) to an actual character (i.e. ,)
There is no built in way to do so. The closest class that could have provided such information is CharUnicodeInfo, but it does not map names to characters. You'd have to build custom map like following: var nameToChar = new Dictionary<string,char>() { {"period", '.'} }; var ch = nameToChar["period"];

Categories : C#

Converting from a list to numeric in R
Here is a shorter/faster way to turn your data.frame into a numeric matrix: data <- data.matrix(data) There is also data <- as.matrix(data) but one important difference is if your data contains a factor or character column: as.matrix will coerce everything into a character matrix while data.matrix will always return a numeric or integer matrix. data <- data.frame( logical = as.logical(c(TRUE, FALSE)), integer = as.integer(c(TRUE, FALSE)), numeric = as.numeric(c(TRUE, FALSE)), factor = as.character(c(TRUE, FALSE)) ) data.matrix(data) # logical integer numeric factor # [1,] 1 1 1 2 # [2,] 0 0 0 1 as.matrix(data) # logical integer numeric factor # [1,] " TRUE" "1" "1" "TRUE" # [2,] "FALSE" "0"

Categories : R

Converting ARM assembly mnemonics to bytes
All the information you're looking for is in the ARM Architecture Reference Manual. If you look up the b instruction, you'll see its encoding and how it works. Here's the specific instruction you care about: The E is the condition field, which you can look up in this table: For you, it's "execute always". Then the A, which in binary is the 1010 to match bits 27:24 (you have a branch instruction, not a branch & link instruction). Lastly the rest of the instruction is the immediate offset field. It's a PC-relative offset, which is why it's encoded as 0x00004b. Let's look at your specific example now. You have the instruction: b 0x00002B78 located at address 0x00002a44. OK, great. So first off, we can stick in the opcode bits: cccc 101L xxxx xxxx xxxx xxxx xxxx xxxx N

Categories : Assembly

Converting two bytes into 16 bit signed number
Since you are performing some widening conversions, you have to stop the propagation of leading 1 bits due to the internal usage of two's complement: byte[] bytes = {0, -128}; // bytes[0] = 0000 0000, bytes[1] = 1000 0000 short s = (short) (((bytes[0] & 0xFF) << 8) | (bytes[1] & 0xFF)); System.out.println(s); // prints 128 Also, float is for floating point numbers, since you want a 16 bit decimal number I changed the target datatype to short.

Categories : Java

Powershell: Converting from bytes into gigabytes
Divide the value by 1GB (or 1MB): $Computers = Get-Content "D:DISKSPACE_auditServers.txt" gwmi Win32_LogicalDisk -Computer $Computers -Filter 'DriveType = 3' ` | select SystemName, DeviceID, @{n='FreeSpace';e={[int]($_.FreeSpace/1GB)}}, @{n='Size';e={[int]($_.Size/1GB)}}

Categories : Powershell

Linux read operations requesting duplicate bytes?
I suggest you strace your cat process to see for yourself. On my system, cat reads by 64K chunks, and does a final read() to make sure it read the whole file. That last read() is necessary to make the distinction between a reading a "chunk-sized file" and a bigger file. i.e. it makes sure there is nothing left to read, as the file size could have changed between the fstat() and the read() system calls. Is your "fake file" size being returned correctly to FUSE by stat/fstat() system calls?

Categories : Linux

Perl module to convert between MB/GB/TB without converting to bytes first?
To convert from MB to TB w/o going through Bytes: Number of TB = Number of MB * (Bytes in 1 TB/Bytes in 1 MB) UPDATE: To Generalize: Number of new units = Number of old units * (Bytes in 1 new unit / Bytes in 1 old unit)

Categories : Perl

Chinese character 数 encodes into too many bytes
The most likely things are either: There's an issue with the encoding of your source file, or You have "invisible" characters prior to the 数 in it. You can check both of those by completely deleting the string literal on this line: String s = new String("数"); so it looks like this (note I removed the quotes as well as the character): String s = new String(); and then adding back "u6570" to get this: String s = new String("u6570"); and seeing if your output changes (as 数 is Unicode code point U+6570 and so that escape sequence should be the same character). If it changes, either there's an encoding problem or you had invisible characters in the string prior to the character. You can probably differentiate the two cases by then adding back just that character (via copy and

Categories : Java

Converting varbinary to numeric type in tsql
This issue is resolved by Lamprey! on sqlteam forum. See answer by visiting http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=186457

Categories : C#

Pandas: Converting to numeric, creating NaNs when necessary
First replace all the string values with None, to mark them as missing values and then convert it to float. df['foo'][df['foo'] == '-'] = None df['foo'] = df['foo'].astype(float)

Categories : Python

Java Converting long to bytes - which approach is more efficient
I suggest you look at how the Java code does it. public final void writeLong(long v) throws IOException { writeBuffer[0] = (byte)(v >>> 56); writeBuffer[1] = (byte)(v >>> 48); writeBuffer[2] = (byte)(v >>> 40); writeBuffer[3] = (byte)(v >>> 32); writeBuffer[4] = (byte)(v >>> 24); writeBuffer[5] = (byte)(v >>> 16); writeBuffer[6] = (byte)(v >>> 8); writeBuffer[7] = (byte)(v >>> 0); out.write(writeBuffer, 0, 8); incCount(8); } as you can see, without a loop you have less operation. The fastest way is to not do this at all and instead using Unsafe.writeLong() as this take a long and places it directly into memory instead of breaking it into bytes. This can be more than 10x fa

Categories : Java

Converting a string of '1's and '0's whose length is exactly a multiple of 8 to a certain number of bytes
You could iterate backwards through the string, but reversing it like you suggest might be easier. From there, you can just build the bytes one at a time. A nested for loop would work nicely: unsigned char bytes[8]; // Make sure this is zeroed for (int i=0, j=0; i<str.length(); j++) { for (int k=0; k<8; k++, i++) { bytes[j] >>= 1; if (str[i] == '1') bytes[j] |= 0x80; } } i is the current string index, j is the current byte array index, and k counts how many bits we've set in the current byte. We set the bit if the current character is 1, otherwise we leave it unset. It's important that the byte array is unsigned since we're using a right-shift.

Categories : C++

Error" Parameter is not valid " while converting Bytes into Image
try this public Image byteArrayToImage(byte[] byteArrayIn) { System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter(); Image img = (Image)converter.ConvertFrom(byteArrayIn); return img; }

Categories : C#

Converting 4 bytes in little endian order into an unsigned integer
Hope this helps you unsigned int arr[256]; char ch[256*4] = "your string"; for(int i = 0,k=0;i<256*4;i+=4,k++) { arr[k] = ch[i]|ch[i+1]<<8|ch[i+2]<<16|ch[i+3]<<24; }

Categories : C++

importing column having character numeric in sas
If they're CSV files, TYPEGUESSROWS is not helpful as that is an excel setting. You can modify GUESSINGROWS directly in the proc import instead. Try reading it in with data step, however- then you don't need to GUESS anythng. data one; length column $10 products $25; *or whatever is right; infile "yourfile.csv" dlm=',' dsd lrecl=100 truncover; *or similar depending on your file; input column $ products $; run; Similar for the other dataset.

Categories : Sas

"Error converting data type nvarchar to numeric."
When you call AddWithValue make sure that the type of data you are passing matches the column type. Here's a likely candidate: cmd.Parameters.AddWithValue("@Amount", txtAmount.Text); In this line you are passing a text string to something that clearly wants a numeric value (an amount). You should parse the txtAmount.Text into a decimal first and then pass that value: decimal amount = decimal.Parse(txtAmount.Text); cmd.Parameters.AddWithValue("@Amount", amount); With this code, you may still get an exception if the string in txtAmount.Text can't be parsed into a decimal, but at least then you'll know which value is causing the problem. You can/should do the same with the other values as well to make sure they match their column types.

Categories : C#

Python 3 - on converting from ints to 'bytes' and then concatenating them (for serial transmission)
You are confusing Python byte literal syntax here; you do not need to generate the literal syntax, just the byte value; the bytes() type accepts a sequence of integers too: >>> bytes([255]) b'xff' Applied to your code: SET_BG_COLOR = b'xAAx03x03' for r in range(0,255): red = bytes([r]) blue = bytes([255 - r]) ser.write(SET_BG_COLOR + blue + b'x00' + red + b'xC3') #BGR format or, simpler still: SET_BG_COLOR = [0xAA, 0x03, 0x03] for r in range(0,255): ser.write(bytes(SET_BG_COLOR + [r, 0x00, 255 - r, 0xC3])) #BGR format using literal hex integer notation. Demo for r = 10: >>> SET_BG_COLOR = [0xAA, 0x03, 0x03] >>> r = 10 >>> bytes(SET_BG_COLOR + [r, 0x00, 255 - r, 0xC3]) b'xaax03x03 x00xf5xc3' The hex() function outputs 4 charac

Categories : Python

C# - Download img and converting bytes to bitmap only works with Fiddler open
You can try like this: System.Net.WebRequest request = System.Net.WebRequest.Create(YourURLString); System.Net.WebResponse resp = request.GetResponse(); System.IO.Stream respStream = resp.GetResponseStream(); Bitmap bmp = new Bitmap(respStream); respStream.Dispose(); picturebox1.Image = bmp;

Categories : C#

How to check if character other than alphabet or numeric is pressed
If you want to detect pressed keys, you can use a KeyUpHandler or KeyDownHandler. TextBox t = new TextBox(); t.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { int pressedKey = event.getNativeKeyCode(); } }); You can use the "pressedKey" integer to see what key code user pressed. Also interesting is KeyCodes, which has the codes for special keys. If you want to validate user input instead, the easiest way is with HTML5 form validation. To implement that method, you can set up your field like this: TextBox t = new TextBox(); t.getElement().setAttribute("required", "required"); t.getElement().setAttribute("pattern", "[a-zA-Z0-9]+"); Here's another resource for HTML5 form validation. And another.

Categories : Java

Efficiently converting strings to appropriate numeric types in pandas DataFrame
Refer to the read_csv documentation. If all the thousands separators are decimals, use thousands='.'. For a column with money, write a function that chops off the $ and converts the remaining string into an integer or a float. Pass it to read_csv via converters. (Again, see docs.) I expect any custom converters will be slow -- read_csv is ruthlessly optimized in C -- so use built-in features (e.g., the thousands keyword) wherever possible.

Categories : Python

HTML5 validation error (numeric character reference)
Try using &#8230; instead of &#133; What the spec/message says/means: In a nutshell, the spec says HTML documents cannot contain “control characters”, which cover the HTML character entity numbers &#128; to &#159; So the advise is to use this &#8230;

Categories : HTML

Sum selected rows in a character matrix: error 'x' must be numeric in R
You ought to be using a data frame, not a matrix, since you really have several different data types. I suspect you can read your data in as a data frame to begin with, but if you want to convert what you have in tab.res to a data frame, with numeric values in columns 3-11: tab.res <- as.data.frame(tab.res, stringsAsFactors=FALSE) for (column in 3:11) { tab.res[, column] <- as.numeric(tab.res[, column]) } (And it's generally better to use names instead of column numbers, I know, but as I said, this step is probably unnecessary anyway.)

Categories : R

How to combine character (or numeric) variables with expressions at LEGEND in R
I think that should give you what you want doesn't it ? leg<-as.factor(paste("m =",c(b1,c1,d1))) legend("bottomright", levels(leg), lwd=1, lty=1, col=c(1,2,3), cex=1.25) I may have misassiociated the lines and the legend levels, up to you to correct it ! ;)

Categories : R

Add literal space character to pictured numeric output
I think for this example you don't need to add the space within the <# #> stuff. You can define strings with leading or trailing spaces with s". So if you start with Push addresses and lengths for the prefix and the number s" prefix " -- addr u 123 s>d <# #s #> addr u -- addr u addr2 u2 The word that you want is something that concatenates them, for example: : concatenate Moves the string addr2 u2 to the end of the string addr u >r >r addr u addr2 u2 -- addr u dup >r over r> + r> addr u -- addr u addr+u addr2 swap r@ addr u -- addr u addr2 addr+u u2 cmove r> + ; addr u addr2 addr+u u2 -- ad

Categories : Misc

remove character columns from a numeric data frame
First use is.character to find all columns with class character. However, make sure that your date is really a character, not a Date or a factor. Otherwise use is.Date or is.factor instead of is.character. Then just subset the columns that are not characters in the data.frame, e.g. df[, !sapply(df, is.character)]

Categories : R

how to prevent dataframe columns being classed as character instead of numeric
cbind("A",5,360) is a matrix, which can hold only one type, i.e. character in your case. Use the data.frame method: cbind.data.frame("A",5,360) However, "cycling through some data" is probably the least efficient way to do this in R.

Categories : R

ORA-06502: PL/SQL: numeric or value error: character string buffer too small
CHAR is a fixed-length data type that uses as much space as possible. So a:= a||'one '; will require more space than is available. Your problem can be reduced to the following example: declare v_foo char(50); begin v_foo := 'A'; dbms_output.put_line('length of v_foo(A) = ' || length(v_foo)); -- next line will raise: -- ORA-06502: PL/SQL: numeric or value error: character string buffer too small v_foo := v_foo || 'B'; dbms_output.put_line('length of v_foo(AB) = ' || length(v_foo)); end; / Never use char. For rationale check the following question (read also the links): Oracle datatype: Should I use VARCHAR2 or CHAR

Categories : SQL

Convert numeric character reference notation to unicode string
Use HTMLParser.HTMLParser(): >>> from HTMLParser import HTMLParser >>> h = HTMLParser() >>> s = "&#1502;&#1508;&#1490;&#1513;&#1497;" >>> print h.unescape(s) מפגשי It's part of the standard library, too. However, if you're using Python 3, you have to import from html.parser: >>> from html.parser import HTMLParser >>> h = HTMLParser() >>> s = '&#1502;&#1508;&#1490;&#1513;&#1497;' >>> print(h.unescape(s)) מפגשי

Categories : Python

PL/SQL: numeric or value error: character string buffer too small %ROWTYPE
I bet the problem originates from using Char which is a fixed length string. Not sure where, but somewhere in your code you try to put a Char or varchar2 string of length N into a char of lengh M where M > N.

Categories : Oracle

Python regex to determine whether a character is numeric, alphanumeric or in a specified string
Use str.isalpha() method: >>> 'a'.isalpha() True For testing single character for punctuation or alphanumeric, you can use constants pre-defined in string module: >>> '.' in string.punctuation: True

Categories : Python

Arithmetic overflow error converting numeric to data type while executing stored procedure
Try this one - ALTER PROCEDURE [dbo].[performance] @startdate NVARCHAR(100), --<-- try to use date datatype - DATE, DATETIME, ... @enddate NVARCHAR(100) AS BEGIN SET NOCOUNT ON; SELECT l.LocName , v.Vtype , SUM(DATEDIFF(MI, t.Paydate, t.DelDate)) AS TotalDiff , [dbo].[testfunction]( CONVERT(DECIMAL(10, 1), AVG(CONVERT(NUMERIC(18, 2), DATEDIFF(SS, t.Paydate, t.DelDate)))) ) AS Average FROM dbo.Transaction_tbl t LEFT JOIN dbo.VType_tbl v ON t.vtid = v.vtid LEFT JOIN dbo.Location_tbl l ON t.Locid = l.Locid WHERE dtime BETWEEN CAST(@startdate AS DATETIME) AND CAST(@enddate AS DATETIME) --<-- possible problem AND [status] = 5 --A

Categories : Sql Server

Arithmetic overflow error converting numeric to data type varchar. while passing large date differance
It's generally a good idea to also post the exact error you get in the question. However, here's my guess about what may be happening: I think the error is due to the expression SUM(DATEDIFF(MI,t.Paydate,t.DelDate)), more specifically it's possible that the total value exceeds the signed int max value (2147483647). It is possible because: the DateDiff function returns a signed integer according to MSDN the difference in minutes for a period of 3 years is approximately 1.5M: (select datediff(mi, '2010-01-01', '2013-01-01') --> 1578240). If you sum up about 2000 such records, it's possible that you exceed the signed int range. So, if your error is Arithmetic overflow error converting expression to data type int. consider converting the minute difference to a data type with a wid

Categories : SQL



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