473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading text file with variable field widths

I am using Visual Studio 2005 (VB.Net) to write my app. At some point
the app. need to read a text file with data in columner format. The
problem I have is that the columns are of variable width (not fixed).
Is there a way that I can use white space characters to distinguise
between different fields in a row?

The file is not comma or tab delimited, but it has spaces between
fields. Spaces are present only between individual fields, never in
the fields themselves.

Below is a couple of lines from the file.

1 PH5 902.0 MG 2 T1ORE 1 ORE1 2000 ALL
0.300

1 PH5 902.0 HB% 7 WS101 101 WST1 2000 ALL
0.600

1 PH9 1172.0 FD% 4 WS101 101 WST1 2000 ALL
0.500

Thanks

Nov 8 '06 #1
1 1393
Christie wrote:
I am using Visual Studio 2005 (VB.Net) to write my app. At some point
the app. need to read a text file with data in columner format. The
problem I have is that the columns are of variable width (not fixed).
Is there a way that I can use white space characters to distinguise
between different fields in a row?

The file is not comma or tab delimited, but it has spaces between
fields. Spaces are present only between individual fields, never in
the fields themselves.

Below is a couple of lines from the file.

1 PH5 902.0 MG 2 T1ORE 1 ORE1 2000 ALL
0.300

1 PH5 902.0 HB% 7 WS101 101 WST1 2000 ALL
0.600

1 PH9 1172.0 FD% 4 WS101 101 WST1 2000 ALL
0.500

Thanks
They seem fixed width to me. You just have to decide where the borders
of the fields are.
--
Rinze van Huizen
C-Services Holland b.v
Nov 8 '06 #2

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

Similar topics

4
2596
by: Chuck Anderson | last post by:
I've read some discussions, searched Google, tried pack, unpack, bin2hex, explode, implode, and I just can't figure out how to convert this data. I am trying to read a file with the following format (two examples). 41 6D 74 72 61 6B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 75 05 1A 00 41 6D 74 72 61 6B 20 4F 6E 6C 69 6E 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8F 05 2B 00
6
12726
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
1
6010
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
5
13106
by: Jonathan Daggar | last post by:
Hello, I'm trying to put together a form with a very tight table formatting. However, every time I put an text-type input field in, the browser pads the area to the right of it with space. I've tried to eliminate it several ways, but it won't go away. It looks like it's forcing at least one space (line break?) in after each field, and then there's some mystery padding on the right that also refuses to go away. I've put up a demo of...
7
2778
by: jamait | last post by:
Hi all, I m trying to read in a text file into a datatable... Not sure on how to split up the information though, regex or substrings...? sample: Col1 Col2 Col3 Col4 A0012430 REKAL TVÄTTMEDEL EKOMAX 0,5L ST 75.9000
7
6098
by: utab | last post by:
Hi there, I am trying to read from a file and at the same time change certain fields of the same field, there are 6 fields in this file like 1 2 3 4 5 6 --------/--------/--------/--------/--------/--------/ // field_width=8 For example, I position my file pointer at the begining of the 4th fileld lets say 25th character(3*(field_width)+1) and when I try to
2
3218
by: Wes Peters | last post by:
Does anyone know of an article that deals with the subject of reading a structured text file using VBA code in Access? Thanks, Wes
4
20727
waynetheengineer
by: waynetheengineer | last post by:
Hello everyone :) I am trying to write VB code for reading filenames and file property values in a specific directory. For example, I have a directory called C:/Bears and in that directory are three files: Brown Bears.txt, Black Bears.txt, and Orange Bears.txt. Each of these files have text descriptions in both the Title property field and the Comments property field of the each file (when you right click the file and select Properties,...
21
3047
by: Stephen.Schoenberger | last post by:
Hello, My C is a bit rusty (.NET programmer normally but need to do this in C) and I need to read in a text file that is setup as a table. The general form of the file is 00000000 USNIST00Z 00000000_00 0 000 000 000 0000 000 I need to read the file line by line and eventually parse out each piece of the file and store in arrays that correspond to the specific
0
8428
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
8339
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
8851
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...
0
8751
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8535
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
7360
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
5650
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
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2757
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

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.