PC Review


Reply
Thread Tools Rate Thread

fixed width text file

 
 
John
Guest
Posts: n/a
 
      13th Jun 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
 
      13th Jun 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
 
      13th Jun 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
 
      13th Jun 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
 
      14th Jun 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
Rate This Thread
Rate This Thread:

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
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 Windows XP Internet Explorer 4 31st Dec 2007 07:55 PM
Fixed-width table not holding width =?Utf-8?B?ZHJwYXVsMTY=?= Microsoft Frontpage 1 26th Sep 2006 12:31 AM
Textbox width scaling to width of data not width of page? AndrewF Microsoft ASP .NET 1 10th Oct 2005 05:38 PM
Fixed Width - Opening Certain Fixed Width Files Jan Microsoft Excel Programming 2 30th Dec 2003 09:31 PM
slow, hanging browser FIXED FIXED FIXED! Resvon Windows XP Internet Explorer 0 1st Oct 2003 04:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 AM.