Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a MySQL table from a list of terms in a text file
    text
    copied!<p>I have a text file with a long list of terms (approx 800) sorted alphabetically in the format:</p> <pre> aword bword cword ... </pre> <p>I would like to use this file to create a new MySQL table where each term is a field, all with the property VARCHAR(5).</p> <p>Would be best if the fields were inserted in the order in which they appear in the file as I also use this file in scripts for content analysis and it would be easier if the (alphabetical) order was maintained when it came time to insert data into this new table. </p> <p>For those curious, I am a student doing a thesis project in the history of science that involves content analysis. The fields will be used to hold frequency data. There will be another field that will the primary key and link these fields with other data. I am no programmer, but do have 10 years experience running linux and am usually able to figure things out. However, Google has failed me here.</p> <p>EDIT</p> <p>So Damoviso pointed out that what I really needed to do was turn the file into a mySQL command. I used awk and uniq to generate the following:</p> <pre><code>CREATE TABLE keyterms_frq ( filename VARCHAR(20), apperception VARCHAR(5), behaviorism VARCHAR(5), behavioristic VARCHAR(5), behaviorists VARCHAR(5), behaviorist VARCHAR(5), behavior VARCHAR(5), behaviour VARCHAR(5), brain VARCHAR(5), conditioned VARCHAR(5), conditioning VARCHAR(5), condition VARCHAR(5), consciousness VARCHAR(5), conscious VARCHAR(5), experienced VARCHAR(5), experiences VARCHAR(5), experience VARCHAR(5), intellect VARCHAR(5), introspections VARCHAR(5), introspection VARCHAR(5), introspectively VARCHAR(5), introspective VARCHAR(5), intuition VARCHAR(5), memoryimage VARCHAR(5), memory VARCHAR(5), mentality VARCHAR(5), mentally VARCHAR(5), mental VARCHAR(5), mind VARCHAR(5), mirrorscript VARCHAR(5), mirrorwriting VARCHAR(5), unconditioned VARCHAR(5) ); </code></pre> <p>Which is unfortunately still not working, as it generates the following:</p> <blockquote> <p>ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition VARCHAR(5), consciousness VARCHAR(5), conscious VARCHAR(5), experience' at line 1</p> </blockquote> <p>I initially thought there was a limit to how many fields I could generate, but that doesn't seem to be the issue</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