开发者

Collecting Stackoverflow Q and A's in a text file

I think my method is lame, but I cannot think of a better way to do this.

I use Ultraedit text editor to hold all the stuff I cull out of Stackoverflow for PHP and MySQL in a text file. This is my strict format for each new entry:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
TITLE: THIS IS MY TITLE (ALL IN CAPS, FOLLOWD BY A DOTTED LINE)
-------------------------------------------------
...probably a question first (if necessary), then another shorter dotted line
-------------------
...answer(s)...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

So, here开发者_C百科 is an actual entry:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
TITLE: READING FIRST 5 FIELDS OF CSV FILE INTO PHP
-------------------------------------------------
(...with fgetcsv...)
        $row = 1;
        if (($handle = fopen("test.csv", "r")) !== FALSE) {
            while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                $num = count($data);
                echo "<p> $num fields in line $row: <br /></p>\n";
                // iterate over each column here
                for ($c=0; $c < $num; $c++) {
                    // handle column data here
                    echo $data[$c] . "<br />\n";
                    // exit the loop after 3rd column parsed
                    if ($c == 2) break;
                }
                ++$row;
            }
            fclose($handle);
-----------------
(...without fgetcsv...)
        $lines = file('data.csv');
        $linecount = count($lines);
        for ($i = 1; $i < $linecount; $i++){
           $fields = explode(',', $lines[$i]);
           $sno  = $fields[0];
           $name = $fields[1];
           $ph   = $fields[2];
           $add  = $fields[3];
        }http://stackoverflow.com/users/login?returnurl=%2fquestions%2fask
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

I can get a list of titles by searching for "TITLE: *", etc. My text file now contains about 15,000 lines. Is there a better way to do this? I have asked StackOverflow before about snippet software, but after a thorough search, there is really nothing out there that fits my needs.

In a way, I'm surprised that there is not a PHP/MySQL application for doing this (collecting snippets). I can't do it because I don't have the knowledge or talent. The snippet collector in my IDE will not suffice.

Thanks!


why not build yourself a little application with a small sql backend (say SQLCE or SQLITE)?

You could build it so that you have the following tables:

  • Title
  • Code Snippet
  • Original Question Url

and then you can relate in the TAGS of the question via another Table to allow better searching/cross referencing.


I have used InfoSelect software for years for this purpose, and have many megabytes of searchable notes and code snippets. It isn't exclusively for code snippets. It's the software equivalent of keeping notes on index cards and being able to arrange them in hierarchies, or do a search on them.

Another similar tool is OneNote which is part of Microsoft Office.

If you remove the condition that your tool should be specifically for tracking code snippets, you may be able to broaden your choices.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜