简体   繁体   English

CSV按字段排序并仅查看选定的行

[英]CSV sorting by field and view only selected rows

I been trying to figure how first read a Google docs CSV (live) to be shown as a custom HTML. 我试图弄清楚如何首先阅读Google文档CSV(实时)以显示为自定义HTML。

The CSV have 50 lines and each line have 15 cells. CSV有50行,每行有15个单元格。

With a bit searching i figure out to this : 经过一点搜索,我发现了这一点:

<?PHP

$file_handle = fopen("https://docs.google.com/spreadsheet/pub?key=0Aus5xZRHSuhydGpmcXBRN0Z2WXM5Sks3TlgydF92R1E&single=true&gid=3&output=csv", "r");

while (!feof($file_handle) ) {

$line_of_text = fgetcsv($file_handle, 1024);

print "<custom code>" . $line_of_text[0] . $line_of_text[1]. $line_of_text[2] . $line_of_text[3] . $line_of_text[4] . $line_of_text[5] . $line_of_text[6] . $line_of_text[7] . $line_of_text[8] . $line_of_text[9] .$line_of_text[10] . $line_of_text[11] . $line_of_text[12] . $line_of_text[13] . $line_of_text[14] . $line_of_text[15] . "<br>";
}

fclose($file_handle);

?>

But what i would need is to view only the row that have the value "(T01S)" in the first cell "A2" or first "$line_of_text[0]" and the header (first line). 但是我需要的是仅查看第一个单元格“ A2”或第一个“ $ line_of_text [0]”和标题(第一行)中具有值“(T01S)”的行。

I was thinking about just to show a "desired_line" would not help me as if i add a line in the middle many pages would show the wrong line. 我只是想显示“ desired_line”对我没有帮助,好像我在中间的许多页面中添加一行会显示错误的行一样。

Also is it any easy way to show one full line except the first cell? 还有一种简单的方法来显示除第一个单元格以外的一个完整行吗? So i can have a custom code on that field? 所以我可以在该字段上使用自定义代码? And also so i do not need every pages code if i add more fields? 另外,如果我添加更多字段,我不需要每个页面代码吗?

After many hours of searching i would be very happy for any kind of help! 经过许多小时的搜索,我将非常高兴获得任何帮助!

Ok i found a easier way doing this using googles own API! 好的,我找到了一种使用Google自己的API的简便方法!

http://spreadsheets.google.com/tq?tqx=out:html&tq=select+A,B,C,D,E,F,I,J+where+A=%27%28T01S%29%27&key=0Aus5xZRHSuhydGpmcXBRN0Z2WXM5Sks3TlgydF92R1E

This page lead me to the right direction : OUseful.Info, the blog… 此页面将我引向正确的方向: OUseful.Info,博客...

And this is the google own page about this : Google Docs Query Language Reference 这是Google自己的网页: Google文档查询语言参考

The google page have a good encoder to query the string on their page. 谷歌页面有一个很好的编码器来查询其页面上的字符串。

So by just using the link string i got exactly what i was looking for. 因此,仅使用链接字符串就可以得到我一直在寻找的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM