473,499 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determing internal format of file

RD
We're picking up files on an FTP server using a vb.net program. We need to
know if the file we pick up is an ASCII comma separated file or if it is in
an Exel format without relying on the extension of the file name
exclusively. So we have to look in the file itself using Vb .Net program
code.

By looking at the contents of the file using a function or sub, how can we
determine reliably if it is an ASCII file or an Excel file?

Thanks for any help,

Bob
Nov 20 '05 #1
2 1345
read 2 or 3 lines - count the commas in each line - if all 3 lines contain
the same number of commas,
i bet its a comma-delimited file - or you could check for chars unique to
excel files (you have to look to see)
"RD" <no****@nospam.net> wrote in message
news:uy**************@TK2MSFTNGP11.phx.gbl...
We're picking up files on an FTP server using a vb.net program. We need to
know if the file we pick up is an ASCII comma separated file or if it is in an Exel format without relying on the extension of the file name
exclusively. So we have to look in the file itself using Vb .Net program
code.

By looking at the contents of the file using a function or sub, how can we
determine reliably if it is an ASCII file or an Excel file?

Thanks for any help,

Bob

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004
Nov 20 '05 #2
> By looking at the contents of the file using a function or sub, how
can we determine reliably if it is an ASCII file or an Excel file?


Prior to Excel 2003 (which changed the format of .xls files), Excel files
were binary files. If you open one in a binary editor (or a good text editor
such as Ultra Edit) you'll find that the first 100 or so bytes primarily
consist of either 0x00 of 0xff characters (there are others too but there
are lots of these). These characters will never appear in a .csv file unless
it has been corrupted. So you could just open it, scan the first 64 bytes or
so and see if any contain 0x00 or 0xff. If they do it's an Excel file. If
they don't, it's not (though that doesn't necessarily mean that is is a .csv
file, of course).

I've no idea about the format in which Excel 2003 files are stored, but
wouldn't be surprised if they're XML-based (in which case they would be
ASCII files, you'll need to find this out).

ASCII files should only ever contain characters in the range 32-127
(inclusive), as well as ascii 10 and 13 (line feed and carriage return).

Hope that's of some help,

--

(O)enone
Nov 20 '05 #3

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

Similar topics

4
3713
by: Patrick Masson | last post by:
Hello, Our configuration : Apache 2.0.53 PHP 5.0.4 PC Windows 2000 MATLAB 6.1 We work on a consulting project in France which involves MATLAB Web server,
2
6782
by: Chien Lau | last post by:
I frequently define internal UserControl-derived classes in my WinForms apps: internal class MyUserControl:UserControl{ ... } I'll often need to embed these controls in a Form, whose class...
2
3881
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
0
262
by: RD | last post by:
We're picking up files on an FTP server using a vb.net program. We need to know if the file we pick up is an ASCII comma separated file or if it is in an Exel format without relying on the...
0
1407
by: Stu | last post by:
Hi, Im using VB dot net and crystal 11 I have a mainReport with a parameter @Idcustomer and in the mainReport I have a subreport @customerId They are linked using crystal. I would like to...
3
7648
by: Robert W. | last post by:
Long ago I developed a simple algorithm for calculating how much space is required to display a multi-line label in a limited width. It seemed to be working okay but then my testing revealed a...
14
2895
by: nishit.gupta | last post by:
Is their any single fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" , It can also...
1
2420
by: =?Utf-8?B?QnJpYW4gQ29iYg==?= | last post by:
This code is contained in one source file in VS 2005 project: using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace ReflectionTest {...
1
1355
by: Hang | last post by:
Hi, We publish our pages in a 3rd party web server, so they host our website. but behind scence data is stored in our internal SQL server, all outside traffic needs go through our router before...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.