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

Home Posts Topics Members FAQ

fixed width text file

I can create text file, but how can I create a text file where the values
are at the same location on every line?

I want to define the location where the values starts and define the length
of the value.
Jun 12 '06 #1
4 2136
If you assume every line was 80 chars in length and append a carriage return
at the end of every line you have something to measure and pad spaces
against. This will give you fixed positioning within the file, but you'll
need to force font to something like courier to see this aligned when you
view it which I dont think you can do in the text file itself. For that
you'll need to use RTF, PDF or something else for that.
--
Regards

John Timney (MVP)

"John" <me@me.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I can create text file, but how can I create a text file where the values
are at the same location on every line?

I want to define the location where the values starts and define the
length of the value.

Jun 13 '06 #2
Tom
each line can be different in length. I get text files now that are fixed
how are they created?
example:
line 1
20060601 BMW 1999 Smith 45,500
20050601 BMW 2003 Jones 75,200
20060102 Lexus 2006 Smith 25,365

and I have to read this files and get all the data, so now I need to create
a file in this format so I can send out and have a vendor read it.

there has to b a way in doing this

"John Timney (MVP)" <x_****@timney. eclipse.co.uk> wrote in message
news:Q6******** ************@ec lipse.net.uk...
If you assume every line was 80 chars in length and append a carriage
return at the end of every line you have something to measure and pad
spaces against. This will give you fixed positioning within the file, but
you'll need to force font to something like courier to see this aligned
when you view it which I dont think you can do in the text file itself.
For that you'll need to use RTF, PDF or something else for that.
--
Regards

John Timney (MVP)

"John" <me@me.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I can create text file, but how can I create a text file where the values
are at the same location on every line?

I want to define the location where the values starts and define the
length of the value.


Jun 13 '06 #3
Thats just looks to be tab delimited data. Try adding vbTab or \t if its
c# to your text string and see if thats what your after.

outputString = "This is text" & vbTab & "and text after tab"

outputString = "This is text text\tand text after tab";

--
Regards

John Timney (MVP)
"Tom" <To*@gmail.co m> wrote in message
news:ep******** ******@TK2MSFTN GP04.phx.gbl...
each line can be different in length. I get text files now that are fixed
how are they created?
example:
line 1
20060601 BMW 1999 Smith 45,500
20050601 BMW 2003 Jones 75,200
20060102 Lexus 2006 Smith 25,365

and I have to read this files and get all the data, so now I need to
create a file in this format so I can send out and have a vendor read it.

there has to b a way in doing this

"John Timney (MVP)" <x_****@timney. eclipse.co.uk> wrote in message
news:Q6******** ************@ec lipse.net.uk...
If you assume every line was 80 chars in length and append a carriage
return at the end of every line you have something to measure and pad
spaces against. This will give you fixed positioning within the file,
but you'll need to force font to something like courier to see this
aligned when you view it which I dont think you can do in the text file
itself. For that you'll need to use RTF, PDF or something else for that.
--
Regards

John Timney (MVP)

"John" <me@me.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I can create text file, but how can I create a text file where the values
are at the same location on every line?

I want to define the location where the values starts and define the
length of the value.



Jun 13 '06 #4
here's a better way =)

// 12345 12345
// will output "abc | def"
Console.WriteLi ne("{0,-5}|{1,5}", "abc", "def");
// this will also produce the same results, but stored in
// a string so you can output it to a text filee
string str = string.Format(" {0,-5}|{1,5}", "abc", "def");

Console.ReadLin e();

in the format string "{0,-5}", the -5 says "pad to a width of 5 spaces,
and put the data on the left"
the "{0,5}" says "pad to a width of 5 spaces, and put the data on the
right"

this isn't going to work if you have data that is 6 or more characters
long, it'll just write the whole word out, but you could always to a
"longdata".Subs tring(0, 5) to grab the first 5 characters

sound good?

John Timney (MVP) wrote:
Thats just looks to be tab delimited data. Try adding vbTab or \t if its
c# to your text string and see if thats what your after.

outputString = "This is text" & vbTab & "and text after tab"

outputString = "This is text text\tand text after tab";

--
Regards

John Timney (MVP)
"Tom" <To*@gmail.co m> wrote in message
news:ep******** ******@TK2MSFTN GP04.phx.gbl...
each line can be different in length. I get text files now that are fixed
how are they created?
example:
line 1
20060601 BMW 1999 Smith 45,500
20050601 BMW 2003 Jones 75,200
20060102 Lexus 2006 Smith 25,365

and I have to read this files and get all the data, so now I need to
create a file in this format so I can send out and have a vendor read it.

there has to b a way in doing this

"John Timney (MVP)" <x_****@timney. eclipse.co.uk> wrote in message
news:Q6******** ************@ec lipse.net.uk...
If you assume every line was 80 chars in length and append a carriage
return at the end of every line you have something to measure and pad
spaces against. This will give you fixed positioning within the file,
but you'll need to force font to something like courier to see this
aligned when you view it which I dont think you can do in the text file
itself. For that you'll need to use RTF, PDF or something else for that.
--
Regards

John Timney (MVP)

"John" <me@me.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
I can create text file, but how can I create a text file where the values
are at the same location on every line?

I want to define the location where the values starts and define the
length of the value.



Jun 14 '06 #5

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

Similar topics

1
3523
by: Jaz | last post by:
Trying to use a fixed layer for a couple of NAV buttons. I found this code, but the IE part is commented, and I don't understand the IF statement. It works great on Moz/Firebird and Opera BUT not IE. Would someone please take a look at this and tell me if it can made to work in IE? If it can, a hint on the syntax/code would be much appreciated! PS, this would also get rid of my fixed background. Thanks in advance Jaz
179
44353
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
4
1998
by: Charles Russell | last post by:
I am trying to have a fixed top and side sections with scrolling content. Both side sections have navigation links. The side provides external navigation and the top provides internal navigation. The styles I have defined work fine until I move to an internal link. When moving to the internal link the header vanishes. This is the style definition as it now stands: /*Creates a fixed left sidebar and header with scrolling content */...
5
11565
by: Johnny Meredith | last post by:
I have seven huge fixed width text file that I need to import to Access. They contain headers, subtotals, etc. that are not needed. There is also some corrupt data that we know about and can correct once the data is in Access (or during the import process itself). Furthermore, the text files are poorly set up, such that some records may be "shifted" over a few characters, and therefore the fixed width nature of the file is corrupted. ...
2
2501
by: Oliver | last post by:
Hi all. Using Access 2000. Trying to import fixed width file that has column headings that I want to becom field names - it's not an option :( Is there a way to achieve this? Thanks Oliver
2
1703
by: Brian Henry | last post by:
In C++ you could easily create a fixed with string by creating it with char(50) or so as an example. This made it easy to write data out to a flat file with a fixed width column. What is the best way in .NET to write to a fixed width flat file? Being that the data going ot a specific column may or may not be over or under the specified width. The data must be truncated or padded to meed the fixed width. Is there any simple way to do this or...
1
3764
by: ghadley_00 | last post by:
Hi, I have a MS access database table for which I regularly need to import fixed width text data. At present I have to to cut and paste the text data from its source to a text file, save the file, import the text file as fixed width text , and then run an update query to copy the appropriate info into fields of a different table. Is it possible to write a macro to do all these steps? Also, is it
1
3168
by: kendrick82 | last post by:
Hi, I would like to seek some advise and assistance regarding the following matter as I am new to VB.Net. I'll appreciate any helps render. I am developing a VB application using VB.Net 2003 to extract data from text files and import it into datatable. The format of the text file is fixed length/width. Eg. http://img174.imageshack.us/img174/8457/untitledpp4.jpg I am having trouble to do so as I am not sure how to start. I had done...
4
3983
by: Jeff | last post by:
Hey I'm wondering how the Fixed-Width Text Format is What I know is that the top line in this text format will contain column names. and each row beneath the top line represent for example a row in a table etc... But does fixed-with mean that every column has a fixed with: for example first column is 10 char wide and second column is 30 char wide?
0
8385
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
8821
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
8502
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
8602
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
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...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1941
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.