Does anyone have any idea what this Asc function is doing (-64)? Thanks again in advance.
Access - IIF(Trim(NZ(MCATw)) = "", 0, Abs(Asc(UCase(MCATw)) -64)) as MCATwNo
I don't understand what the -64 is doing?
It's probably converting the first letter of a string to a numeric value 1-26. The upper case letters A - Z have ASCII values of 65 - 90, so ASC("A") becomes 65, and 65 - 64 is 1. Thus A - Z becomes 1 - 26. Assuming that MCATw is a string, ASC will only apply to the first character.
Related
I am writing a Go program that communicates with MySQL.
I have the following column:
lot_size double(8,8)
I'm ingesting an xml feed and parsing it in Go. Here is the data dump of the lot_size xml data
(string) (len=4) "0.36"
Also, sometimes it can be:
(string) ""
In my Go program, I have the following conversion:
if listings.Listings[i].LotSize == "" {
lotSize=0.00000000
} else {
lotSize,_=strconv.ParseFloat(listings.Listings[i].LotSize,8)
}
Mysql is producing the following error:
Error 1264: Out of range value for column 'lot_size' at row 1
Not sure what to do at this point
UPDATE
HERE is the parsed float data output:
(float64) 0
34 (float64) 0.410239
35 (float64) 0.045914
36 (float64) 0.325941
37 (float64) 0.208425
38 (float64) 0.078627
39 (float64) 0.132989
40 (float64) 0.163522
41 (float64) 0.24
42 (float64) 0.230119
43 (float64) 0
44 (float64) 4.25
my sql query is:
insert into listings (lot_size) values (?)
stmt,err:=db.Prepare(sqlStatement)
res,err:=stmt.Exec(lotSize)
The answer discussed in comments above boils down to this:
MySQL FLOAT(8,8) type means the value may have eight digits, but all eight must be to the right of the decimal. This means any value 1.0 or greater cannot be stored in this column if you declare a FLOAT with two argument that are the same number.
This behavior is documented here: https://dev.mysql.com/doc/refman/8.0/en/floating-point-types.html
By the way, this nonstandard form of FLOAT with two arguments is deprecated in MySQL 8.0.17 and will be removed in a future version of MySQL. It's recommended to use DECIMAL instead.
I have the following values that I would like to present via piaChart
3.0283506
0.25773194
95.87629
0.83762884
How can I configure the dataLabelFormatString so it will show also values that are less than 1 so the result will look like this:
3.02
0.25
95.8
0.83
Thanks
If i understand correctly you want to show the first 4 chars of your values?
In that case you want to use %4.4s in your dataLabelFormatString.
double num1 = 3.0283506;
double num2 = 0.25773194;
double num3 = 95.87629;
double num4 = 0.83762884;
System.out.format("%4.4s%n", num1);
System.out.format("%4.4s%n", num2);
System.out.format("%4.4s%n", num3);
System.out.format("%4.4s%n", num4);
produces:
3.02
0.25
95.8
0.83
It is possible to place the decimal format datalabel by using the setting.
rendererOptions: {
fill: true,
showDataLabels: true,
dataLabelFormatString: '%.2f%'
}
When i try to store text containing 'C' code in MS ACCESS table (programatically). It replaces escape sequences ('\n', '\t') with some question-mark symbol.
Example :
code to store :
#include<stdio.h>
int main()
{
printf("\n\n\t Hi there...");
return 0;
}
When i see MS-Access table for above inserted code it shows every newline and '\t' character replaced with a '?' kind of symbol.
My question "is there any other data type for MS-Access filed which stores code as it is without replacing escape sequences with some symbol?"
and
"Is 'raw' data type present in other DBMS like MYSQL will do my job? "
This is how it shows in access-07 :
It looks like the line breaks in your source text are not the Windows-standard CRLF (carriage return, line feed). Find out the character codes of those mystery characters.
Using the procedure below, I can feed it a text string, and it will list the code of each character. Here is an example from the Immediate window.
AsciiValues "a" & vbcrlf & "b"
position Asc AscW
1 97 97
2 13 13
3 10 10
4 98 98
If I want to examine the value stored in a table text field, I can use DLookup to fetch that value and feed it to the function.
AsciiValues DLookup("memo_field", "tblFoo", "id=1")
position Asc AscW
1 108 108
2 105 105
3 110 110
4 101 101
5 32 32
Once you determine the codes of the problem characters, you can execute an UPDATE statement to replace the problem character codes with suitable alternatives.
UPDATE YourTable
SET YourField = Replace(YourField, Chr(x), Chr(y));
And this is the procedure ...
Public Sub AsciiValues(ByVal pInput As String)
Dim i As Long
Dim lngSize As Long
lngSize = Len(pInput)
Debug.Print "position", "Asc", "AscW"
For i = 1 To lngSize
Debug.Print i, Asc(Mid(pInput, i, 1)), AscW(Mid(pInput, i, 1))
Next
End Sub
I'd say it's probably that you're lacking the whole newline. A newline in Access consists of a Carriage Return (ASCII 13) AND a Line Feed (ASCII 10). This is abbreviated as CRLF. You probably only have one or the other, but not both.
Use HansUp's AsciiValues procedure to take a look.
i have an application which converts each character in my string to 3digit number, it seems to be something like ASCII but its not that, im trying to figure it out but i cant understand:
somefunction(){
a => 934 // a will be converted to 934
b => 933 // b will be converted to 933
1 => 950 // 1 will be converted to 950
0 => 951 // 0 will be converted to 951
}
i know ASCII but i don't understand this, please help if know what type of encoding type this is.
Thanks You :)
Here's one possibility (ord returns the ASCII value of the character), but I think you'd really need several more data points to know for certain.
>>> for c in 'ab10': print c, 999 - ord(c.upper())
...
a 934
b 933
1 950
0 951
I'm accessing public mySQL database using JDBC and mySQL java connector. exonCount is int(10), exonStarts and exonEnds are longblob fields.
javaaddpath('mysql-connector-java-5.1.12-bin.jar')
host = 'genome-mysql.cse.ucsc.edu';
user = 'genome';
password = '';
dbName = 'hg18';
jdbcString = sprintf('jdbc:mysql://%s/%s', host, dbName);
jdbcDriver = 'com.mysql.jdbc.Driver';
dbConn = database(dbName, user , password, jdbcDriver, jdbcString);
gene.Symb = 'CDKN2B';
% Check to make sure that we successfully connected
if isconnection(dbConn)
qry = sprintf('SELECT exonCount, exonStarts, exonEnds FROM refFlat WHERE geneName=''%s''',gene.Symb);
result = get(fetch(exec(dbConn, qry)), 'Data');
fprintf('Connection failed: %s\n', dbConn.Message);
end
Here is the result:
result =
[2] [18x1 int8] [18x1 int8]
[2] [18x1 int8] [18x1 int8]
result{1,2}'
ans =
50 49 57 57 50 57 48 49 44 50 49 57 57 56 54 55 51 44
This is wrong. The length of vectors in 2nd and 3rd columns should match the numbers in the 1st column.
The 1st blob, for example, should be [21992901; 21998673]. How I can convert it?
Update:
Just after submitting this question I thought it might be hex representation of a string.
And it was confirmed:
>> char(result{1,2}')
ans =
21992901,21998673,
So now I need to convert all blobs hex data into numeric vectors. Still thinking to do it in a vectorized way, since number of rows can be large.
This will convert your character data to numeric vectors for all except the first column of data in result, placing the results back into the appropriate cells:
result(:,2:end) = cellfun(#(x) str2num(char(x'))',... %# Apply fcn to each cell
result(:,2:end),... %# Input cells
'UniformOutput',false); %# Output as a cell array
I suggest using textscan
exons = cellfun(#(x) textscan(char(x'),'%d','Delimiter',','),...
result(:,2:end),'UniformOutput',false);
To get a cell array for each of the two numbers, you can replace the format string by %d,%d and drop the Delimiter option.
Here is what I do:
function res = blob2num(x)
res = str2double(regexp(char(x'),'[^,]+','match')');
then
exons = cellfun(#blob2num,result(:,2:3)','UniformOutput',0)
exons =
[2x1 double] [2x1 double]
[2x1 double] [2x1 double]
Any better solution? May be on the step of retrieving data?