开发者

How can I format a text file to print in columns?

I have a bunch of fields that I want to print in a table format. The problem is that the file is tab-delimited, and depending on the length of the previous field, the tabs sometimes line up 开发者_开发知识库and sometimes they don't.

Is there a way I can fix this? (like a nice HTML table)? Would changing the file to CSV (comma-separated value) fix this issue?


Assign each column to an array, then use a string length function on each element in the array to determine the maximum size of each column. When you print out the data, you can difference the strlen of the actual field from the maximum column size to determine how much padding that particular entry needs after the string is printed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜