473,624 Members | 2,290 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 1357
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******** ******@TK2MSFTN GP11.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
3717
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
6797
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 is contained in the same assembly as the control. As far as I know, the only way to do this using the designer is to add the UserControl-derived object
2
3887
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 is used - is it accurate way? 2. I have the following code blocks - In code block 1, the first check the DistributedIdentifier is ALL 0s so it
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 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...
0
1418
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 determing in the subreport the parameter name it is linked to in this case @customerId is linked to @idCustomer using code. I know there is a subreports link collection but unsure how to use it. Any ideas/code samples
3
7652
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 flaw when trying to display the following string with an MS Sans Serif 8 point font in a 208 pixel width space: "A $50-million investment in cycling infrastructure - the largest history of the province" Using the Graphics "MeasureString"...
14
2916
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 contain zero
1
2431
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 { internal class x
1
1365
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 reach the SQL server, so in the Web Configuration file, in connection string entry, "Data Source", what should I put in, I tried the router IP address, it won't work; I also tried our SQL IP address, it won't work either because the IP address is...
0
8242
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7170
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
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 we have to send another system
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.