473,320 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to identify file formats?

Hi,

I need to find a way to identify between a few different file formats
WITHOUT looking at the file extension. Very often our customers will name
file incorrectly. For example, they'll send us a file that's named
'filename.xls', but it's actually a tab delimited or comma delimited file.

The possible formats that I need to identify are: HTML, tab delimited, comma
delimited or Excel.
Nov 21 '05 #1
4 1920
Eric,

This seems to me if the extentions are made for nothing and that it is
possible to find the format by its content. Is this not a strange question
therefore?

I think that than there would have been never extentions, it was hard to get
that dicipline with users (and you even did not manage that with yours).

Another case is if a file does not has the file format it need to have,
however that will probably fail directly in a try and catch when you have
done it right.

Just my thought,

Cor
"Eric" <Er**@discussions.microsoft.com>
Hi,

I need to find a way to identify between a few different file formats
WITHOUT looking at the file extension. Very often our customers will name
file incorrectly. For example, they'll send us a file that's named
'filename.xls', but it's actually a tab delimited or comma delimited file.

The possible formats that I need to identify are: HTML, tab delimited,
comma
delimited or Excel.

Nov 21 '05 #2
You can guess for well known formats like Excel or HTML by looking at the
header. But it would be next to impossible to distinguish tab-delimited and
comma seperated, unless you have stringent rules of enclosing string values
in quotes etc.

Rgds,
Anand M
http://www.dotnetindia.com

"Eric" wrote:
Hi,

I need to find a way to identify between a few different file formats
WITHOUT looking at the file extension. Very often our customers will name
file incorrectly. For example, they'll send us a file that's named
'filename.xls', but it's actually a tab delimited or comma delimited file.

The possible formats that I need to identify are: HTML, tab delimited, comma
delimited or Excel.

Nov 21 '05 #3
Eric schrieb:
I need to find a way to identify between a few different file formats
WITHOUT looking at the file extension. Very often our customers will name
file incorrectly. For example, they'll send us a file that's named
'filename.xls', but it's actually a tab delimited or comma delimited file.

The possible formats that I need to identify are: HTML, tab delimited, comma
delimited or Excel.


You'll have to analyze the file's content/header.

Some file format specifications can be found here:

<URL:http://www.wotsit.org/>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #4
On Wed, 8 Dec 2004 17:05:03 -0800, "Eric" <Er**@discussions.microsoft.com> wrote:

¤ Hi,
¤
¤ I need to find a way to identify between a few different file formats
¤ WITHOUT looking at the file extension. Very often our customers will name
¤ file incorrectly. For example, they'll send us a file that's named
¤ 'filename.xls', but it's actually a tab delimited or comma delimited file.
¤
¤ The possible formats that I need to identify are: HTML, tab delimited, comma
¤ delimited or Excel.

Can't be done programmatically. There is nothing particularly unique about tab delimited or comma
delimited files (other than the delimiter).

Unless you add a customized header or identifier of some type you won't likely be able to tell them
apart without looking at them.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Subodh | last post by:
Hi, Currently we get data from more then 200 different sources and all of our vendors provide data in different file formats. The problem is we have more then 100 DTS packages now and the...
3
by: Tanuki | last post by:
Hi All: I encounter a programming problem recently. I need to read a binary file. I need to translate the binary data into useful information. I have the format at hand, like 1st byte = ID,...
12
by: Danny Lu | last post by:
Can anyone tell me if all the .obj or .o files are compatible?
7
by: Bart | last post by:
When I try to upload a file from whithin a form, it works locally. But when i deploy my asp.net application, i got the error 'uri formats are not supported'. I thought it has something to do...
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
4
by: NancyJ | last post by:
Currently we have a database with a main table containing 3 million records - we want to increase that to 10 million but thats not a possibility at the moment. Nearly all 3 million records are...
1
by: feltra | last post by:
Hi, The following is from my friend who has only restricted net access from his office and hence cannot post.... ...
0
by: feltra | last post by:
Hi all, I am trying to export a GridView data to multiple file formats. The requirement is that when more than one file format is selected and the "Submit" button is clicked, the data from the...
2
by: Peter Oliphant | last post by:
The Image class allows loading a bitmap from a graphic file. So far I've gotten it to work with JPG and BMP files. What other graphic file formats are supported in this way? Is this fixed based...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.