Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > fixed width text file

Reply
Thread Tools

fixed width text file

 
 
John
Guest
Posts: n/a
 
      06-12-2006
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.


 
Reply With Quote
 
 
 
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      06-13-2006
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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.
>



 
Reply With Quote
 
 
 
 
Tom
Guest
Posts: n/a
 
      06-13-2006
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)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>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.
>>

>
>



 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      06-13-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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)" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>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.
>>>

>>
>>

>
>



 
Reply With Quote
 
digitaljeebus@gmail.com
Guest
Posts: n/a
 
      06-14-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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)" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:%(E-Mail Removed)...
> >>>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.
> >>>
> >>
> >>

> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Fixed width table with a 100% width image in it is assuming theimages intrinsic size, although it does shrink the image satya.komatineni@gmail.com HTML 1 12-29-2007 08:32 PM
CSS question: Using height/width at 100% with fixed-width borders/margin/padding cera HTML 1 08-18-2007 02:59 AM
fixed-width column and variable-width columns mixed ssk HTML 5 10-30-2006 07:50 AM
Free Fixed-Width/Fixed-Pitch fonts? johnp HTML 4 05-23-2005 06:14 AM
Fixed layout width based on browser window width msswasstastic@aol.com HTML 11 01-28-2005 07:36 AM



Advertisments