开发者

Displaying multiple CSV file contents as HTML tables using pagination in PHP

I have multiple CSV files, each with the same set of row/column titles but each with different values. For example:

CSV-1.csv
A,B,C,C,C,X
A,A,A,A,C,X

CSV-2.csv
A,C,C,C,C,X
A,C,A,A,C,X

and so on...

I have been ab开发者_开发知识库le to figure out how to read the files and convert them into HTML pre-formatted tables. However, I have not been able to figure out how to paginate when there are multiple files with data (as shown above) such that I get only a single table at a time with "Next" and "Previous" buttons (to be able to effectively see the changes in the table and data.

Any ideas would be greatly appreciated.


If you know in advance what the files are, then predetermining the line count for each file would let you do the pageination.

Then it'd be a simple matter of scanning through this line count cache to figure out which file to start reading from, and just keep reading lines/files until you reach the per-page line limit.

Otherwise, you option will be to open/read each file upon each request, but only start outputting when you reach the file/line that matches the current "page" offset. For large files with many lines, this'd be a serious waste of cpu time and disk bandwidth.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜