Re: binary vs. text?

2006-12-12 Thread Chris Sheffield
Thanks to everyone for your suggestions. I'll probably go with this one from Mark, even though Sarah's was very good. Since my files will have to be in a certain format anyway, it's easy for me just to verify the data. Chris On Dec 11, 2006, at 4:03 PM, Mark Schonewille wrote: When you

binary vs. text?

2006-12-11 Thread Chris Sheffield
Does anyone have a sure fire way to determine if a file is binary or text? I have need to create an import utility that will import data from a text file (csv, tab-delimited, etc) into a database, but I'd like to check the file before doing anything else just to make sure it is in fact

Re: binary vs. text?

2006-12-11 Thread Sarah Reichelt
On 12/12/06, Chris Sheffield [EMAIL PROTECTED] wrote: Does anyone have a sure fire way to determine if a file is binary or text? I have need to create an import utility that will import data from a text file (csv, tab-delimited, etc) into a database, but I'd like to check the file before doing

Re: binary vs. text?

2006-12-11 Thread Ruslan Zasukhin
On 12/12/06 12:09 AM, Chris Sheffield [EMAIL PROTECTED] wrote: Hi Chris, Does anyone have a sure fire way to determine if a file is binary or text? I have need to create an import utility that will import data from a text file (csv, tab-delimited, etc) into a database, but I'd like to

Re: binary vs. text?

2006-12-11 Thread Chris Sheffield
Thanks, Sarah. Very cool idea. Seems to work for me. Can anyone thing of any cases that this might fail? On Dec 11, 2006, at 3:14 PM, Sarah Reichelt wrote: On 12/12/06, Chris Sheffield [EMAIL PROTECTED] wrote: Does anyone have a sure fire way to determine if a file is binary or text? I

Re: binary vs. text?

2006-12-11 Thread Ruslan Zasukhin
On 12/12/06 12:15 AM, Ruslan Zasukhin [EMAIL PROTECTED] wrote: On 12/12/06 12:09 AM, Chris Sheffield [EMAIL PROTECTED] wrote: Hi Chris, Does anyone have a sure fire way to determine if a file is binary or text? I have need to create an import utility that will import data from a text

Re: binary vs. text?

2006-12-11 Thread Eric Chatonet
Hi Chris, Sarah's answer sounds good (I mean fully reliable) but may appear unusable with heavy files you download from the internet. As for us we use another method based on statistics by checking charToNum's chars. On Windows, it appears that checking 60 chars and finding more than 3

Re: binary vs. text?

2006-12-11 Thread Geir A. Myrestrand
Chris Sheffield wrote: Does anyone have a sure fire way to determine if a file is binary or text? There is no such thing as a sure fire way to determine if it is text or not, unless the definition of text can be clearly defined. I have need to create an import utility that will import data

Re: binary vs. text?

2006-12-11 Thread Chris Sheffield
Thanks, Eric. I shouldn't have a problem with Sarah's method since these files will not be downloaded from the internet at all. On Dec 11, 2006, at 3:23 PM, Eric Chatonet wrote: Hi Chris, Sarah's answer sounds good (I mean fully reliable) but may appear unusable with heavy files you

Re: binary vs. text?

2006-12-11 Thread Geir A. Myrestrand
Sarah Reichelt wrote: On 12/12/06, Chris Sheffield [EMAIL PROTECTED] wrote: Does anyone have a sure fire way to determine if a file is binary or text? I have need to create an import utility that will import data from a text file (csv, tab-delimited, etc) into a database, but I'd like to check

Re: binary vs. text?

2006-12-11 Thread Mark Schonewille
Hi Sarah, You can't do that. Crlf is translated by Rev into linefeed on DOS cr is also translated into linefeed oin Mac OS 9, which means that a text file is never equal to its binary equivalent. Best, Mark -- Economy-x-Talk Consultancy and Software Engineering http://economy-x-talk.com

Re: binary vs. text?

2006-12-11 Thread Mark Schonewille
Ruslan, You can't do that, because there are about a dozen different unicode signatures and some streams have no unicode signature at all. Best, Mark -- Economy-x-Talk Consultancy and Software Engineering http://economy-x-talk.com http://www.salery.biz Get your store on-line within

Re: binary vs. text?

2006-12-11 Thread Ruslan Zasukhin
On 12/12/06 12:55 AM, Mark Schonewille [EMAIL PROTECTED] wrote: Ruslan, You can't do that, because there are about a dozen different unicode signatures and some streams have no unicode signature at all. Hi Mark, We do this for Valentina studio. :-) Of course can be file without signature.

Re: binary vs. text?

2006-12-11 Thread Dave Cragg
On 11 Dec 2006, at 22:21, Chris Sheffield wrote: Thanks, Sarah. Very cool idea. Seems to work for me. Can anyone thing of any cases that this might fail? I think this would only work if you can be sure that the line endings in the text files are unix style (numToChar(10)). If, for

Re: binary vs. text?

2006-12-11 Thread Mark Schonewille
Chris, When you import a file, you always want to do something with its contents. Just check to see if the text contents fits the destination. If not, it might be a binary file and you may need to handle it differently. There is another way. You could do a guess about the percentage of

Re: binary vs. text?

2006-12-11 Thread Dar Scott
On Dec 11, 2006, at 3:09 PM, Chris Sheffield wrote: Does anyone have a sure fire way to determine if a file is binary or text? I have need to create an import utility that will import data from a text file (csv, tab-delimited, etc) into a database, but I'd like to check the file before