473,320 Members | 1,766 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,320 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 2107
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: 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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.