473,326 Members | 2,732 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,326 software developers and data experts.

Writing Data In Tabular format in Text File.

Hi guys,
i want to write some data in tabular format in text file. i've data in
strings and i want to write like this in file

col1 col2 col3

d1 d1 d1
d2 d2 d2
d3 d3 d3

the problem is, i dont know how can i maintain spaces between the
columns as i dont know which column will have what length of text.

in c++, i think u can do by adding padding to make sure the alignment
remains correctly but i dont know how can i do that in c#.

i would appriciate your help,

thanks
Lucky

Oct 17 '06 #1
3 5263
Hi lucky,

Unfortunately, I think you should:

A. Try to find out what the maximum length is of a single cell in all
columns, and add enough whitespace to the other cells while writing to
the text file.

or

B. Start with a single whitespace, and each time you encounter a cell
that would require a previous cell in the column to have more
whitespace, to go back and review all cells in the column (and give
them more whitespaces).

Of course, option B is far more expensive, so you should really try to
know beforehand. I guess this is just a limitation of the constraints
you pose (use txt file and use whitespace).

Btw it feels like txt is perhaps not your best option here? Can't you
save in html and use tables or use a comma-delimited file?

Anyway, hope this helps.

Regards,
Jeroen
lucky schreef:
Hi guys,
i want to write some data in tabular format in text file. i've data in
strings and i want to write like this in file

col1 col2 col3

d1 d1 d1
d2 d2 d2
d3 d3 d3

the problem is, i dont know how can i maintain spaces between the
columns as i dont know which column will have what length of text.

in c++, i think u can do by adding padding to make sure the alignment
remains correctly but i dont know how can i do that in c#.

i would appriciate your help,

thanks
Lucky
Oct 17 '06 #2
hey pal,
thanks for replay. i'm thinking about the first option from the
begining but i wanted to take a chance to ask you people if someone
knows some other way of doing.

the reason why i can't use html or csv file is, i'm write data into the
log file and this file has different kind of data. The data that i need
to write is just a small part of it. that is why i didnt want to write
a long code to find the lenght of data and then format ir. but it
seems. i dont have another way..

thanks anyways,
Lucky

Jeroen wrote:
Hi lucky,

Unfortunately, I think you should:

A. Try to find out what the maximum length is of a single cell in all
columns, and add enough whitespace to the other cells while writing to
the text file.

or

B. Start with a single whitespace, and each time you encounter a cell
that would require a previous cell in the column to have more
whitespace, to go back and review all cells in the column (and give
them more whitespaces).

Of course, option B is far more expensive, so you should really try to
know beforehand. I guess this is just a limitation of the constraints
you pose (use txt file and use whitespace).

Btw it feels like txt is perhaps not your best option here? Can't you
save in html and use tables or use a comma-delimited file?

Anyway, hope this helps.

Regards,
Jeroen
lucky schreef:
Hi guys,
i want to write some data in tabular format in text file. i've data in
strings and i want to write like this in file

col1 col2 col3

d1 d1 d1
d2 d2 d2
d3 d3 d3

the problem is, i dont know how can i maintain spaces between the
columns as i dont know which column will have what length of text.

in c++, i think u can do by adding padding to make sure the alignment
remains correctly but i dont know how can i do that in c#.

i would appriciate your help,

thanks
Lucky
Oct 17 '06 #3
Lucky wrote:
hey pal,
thanks for replay. i'm thinking about the first option from the
begining but i wanted to take a chance to ask you people if someone
knows some other way of doing.

the reason why i can't use html or csv file is, i'm write data into the
log file and this file has different kind of data. The data that i need
to write is just a small part of it. that is why i didnt want to write
a long code to find the lenght of data and then format ir. but it
seems. i dont have another way..

thanks anyways,
Lucky

Jeroen wrote:
>>Hi lucky,

Unfortunately, I think you should:

A. Try to find out what the maximum length is of a single cell in all
columns, and add enough whitespace to the other cells while writing to
the text file.

or

B. Start with a single whitespace, and each time you encounter a cell
that would require a previous cell in the column to have more
whitespace, to go back and review all cells in the column (and give
them more whitespaces).

Of course, option B is far more expensive, so you should really try to
know beforehand. I guess this is just a limitation of the constraints
you pose (use txt file and use whitespace).

Btw it feels like txt is perhaps not your best option here? Can't you
save in html and use tables or use a comma-delimited file?

Anyway, hope this helps.

Regards,
Jeroen
lucky schreef:

>>>Hi guys,
i want to write some data in tabular format in text file. i've data in
strings and i want to write like this in file

col1 col2 col3

d1 d1 d1
d2 d2 d2
d3 d3 d3

the problem is, i dont know how can i maintain spaces between the
columns as i dont know which column will have what length of text.

in c++, i think u can do by adding padding to make sure the alignment
remains correctly but i dont know how can i do that in c#.

i would appriciate your help,

thanks
Lucky

Erm.. put tabs between the columns? (vbTab)
--
Rinze van Huizen
C-Services Holland b.v
Oct 17 '06 #4

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

Similar topics

19
by: Johnny Google | last post by:
Here is an example of the type of data from a file I will have: Apple,4322,3435,4653,6543,4652 Banana,6934,5423,6753,6531 Carrot,3454,4534,3434,1111,9120,5453 Cheese,4411,5522,6622,6641 The...
3
by: lucky | last post by:
Hi guys, i want to write some data in tabular format in text file. i've data in strings and i want to write like this in file col1 col2 col3 d1 d1 d1 d2 d2 ...
1
by: kunu601 | last post by:
hi my self uttam . i am working in r & d organization . friends i need a he lp from u . if any one of u know how add two sections(consisting of caption, header, footer ) be displayed on the same...
3
by: maylee21 | last post by:
hi, anyone can help me figure out how to read data from a text file like this: 10980012907200228082002 and extract the data according to this kind of format: Record type 1 TY-RECORD ...
38
by: Sanders Kaufman | last post by:
I'm converting my table-based layouts to css-positioned divs - but the ONLY reason I'm doing it is because it's *considered* a best practice. I don't really see where anything goes hinky when...
2
by: madhu542 | last post by:
Hi, I am trying to print the values of a file in the tabular format... The contents of the file are :- TILE 1: Serial Number: 1 Model Number: 110A Hardware Rev: 220A
1
by: sharan | last post by:
Using the expat parser (http://expat.sourceforge.net/) i have to parse the following xml file and print it on the screen in tabular format using C language. i am getting ouput serially but not in...
7
by: zdravko.monov | last post by:
Hi there! I need a C++ library that can organize and write scientific (and numerical overall) data in tables. I have been fighting with std::ofstream and plain ASCII files, but it is difficult to...
20
by: Marin Brkic | last post by:
Hello all, please, let me apologize in advance. English is not my first language (not even my second one), so excuse any errors with which I'm about to embarass myself in front of the general...
1
by: zwamin | last post by:
can someone let me know the html code for reading a text file with tab delimiter in a webpage in tabular format? number of rows in the text file is not known...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.