473,387 Members | 1,904 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,387 software developers and data experts.

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 1341
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
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
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...

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.