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

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 2101
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****************@TK2MSFTNGP05.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********************@eclipse.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****************@TK2MSFTNGP05.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.com> wrote in message
news:ep**************@TK2MSFTNGP04.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********************@eclipse.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****************@TK2MSFTNGP05.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.WriteLine("{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.ReadLine();

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".Substring(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.com> wrote in message
news:ep**************@TK2MSFTNGP04.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********************@eclipse.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****************@TK2MSFTNGP05.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
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...
179
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
4
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....
5
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...
2
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
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...
1
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...
1
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...
4
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...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.