Note that there are some explanatory texts on larger screens.

plurals
  1. POCollecting Stackoverflow Q and A's in a text file
    text
    copied!<p>I think my method is lame, but I cannot think of a better way to do this.</p> <p>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:</p> <pre><code>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 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)... @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ </code></pre> <p>So, here is an actual entry: </p> <pre><code>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 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 "&lt;p&gt; $num fields in line $row: &lt;br /&gt;&lt;/p&gt;\n"; // iterate over each column here for ($c=0; $c &lt; $num; $c++) { // handle column data here echo $data[$c] . "&lt;br /&gt;\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 &lt; $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 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ </code></pre> <p>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.</p> <p>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.</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload