Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access 7.1.142
  HXTT Cobol 5.0.142
  HXTT DBF 7.1.143
  HXTT Excel 6.1.146
  HXTT Json 1.0.114
  HXTT Paradox 7.1.142
  HXTT PDF 2.0.142
  HXTT Text(CSV) 7.1.142
 
  Buy Now
  Support
  Download
  Document
  FAQ
  HXTT Word 1.1.142
  HXTT XML 4.0.143
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
   
   
   
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT Text(CSV)
Dirty data
Mark
2006-09-27 13:07:28.0
I have some data I need to process, but there is no guarantee it will be valid for integer and double types (e.g. sometimes there will be alpha characters in an integer column). So in the schema I will treat these as varchar. What I want to do is use SQL functions to convert it to the right type if its valid. The problem is, I don't see the right functions for what I want. I would like something like IF(ISDIGIT(field),CINT(field),NULL)) but ISDIGIT only tests the leftmost character.. I want all the characters tested.

Thanks,
Mark
Re:Dirty data
HXTT Support
2006-09-27 20:46:26.0
Now you can use IF(ISDIGITS(field),CINT(field),NULL)) . ISDIGITS, not ISDIGIT:) Please download the latest package.
Re:Re:Dirty data
Mark
2006-09-27 21:37:32.0
Thanks for implementing this.. I think its a very useful feature for dealing with dirty input data -- which is what you find when dealing with text files.

What I forgot to mention before, is that sometimes I may be dealing with floating point data as well. So I think what I also need would be the following in terms of a regex: [-+]?[0-9]+(\.[0-9]+)?
maybe call it isNumber? I hope I am not asking for too much. Thanks for your support.

Regards,
Mark
Re:Re:Re:Dirty data
HXTT Support
2006-09-27 23:28:20.0
GetNumber(str[, defaultValue]): return a number value(int, long, double) according to str. If failed to parse, return defaultValue(null is omitted value).
GetInt(str[, defaultValue]): return an int value according to str. If failed to parse, return defaultValue(null is omitted value).
GetLong(str[, defaultValue]): return a long value according to str. If failed to parse, return defaultValue(null is omitted value).
GetDouble(str[, defaultValue]): return a double value according to str. If failed to parse, return defaultValue(null is omitted value).

GetNumber is a special function, which allows defaultValue to use non-number value. For instance,
select getNumber(field,field),...
Object value=resultSet.getObject(1);
if(value instance Number){//Parsed number, Integer, Double, or Double
}else{
value=restultSet.getString(1);//Now you can see the invalid data format.
}

Please download the latest package.
Re:Re:Re:Re:Dirty data
Mark Diamond
2006-09-28 10:11:02.0
Thank you. I will test it.

I just want to say that this feature (GetNumber,etc) is still very helpful eventhough you have implemented: http://www.hxtt.com/support_view_issue.jsp?id=1159435932
The reason is that some users may want complete control of dealing with dirty data and do some custom workaround vs. having the driver return a null.

Thanks,
Mark


Search Key   Search by Last 50 Questions




Google
 

Email: webmaster@hxtt.com
Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Sitemap