List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:April 4 2000 8:37pm
Subject:Re: Problem reading from a text file
View as plain text  
At 3:33 PM -0400 04-04-2000, Margie Wiers wrote:
>Thanks, everyone, for your suggestions. . .
>
>but I still have not been successful.  I would like to be able to CREATE
>TABLE from a text file, but if I have to, I can CREATE TABLE with just one
>column, which is required, then populate with the text file.  My text file
>contains
>
>_____________________________________
>CREATE TABLE member
>(
>  member_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
>  lastname VARCHAR(20) NOT NULL
>  firstname VARCHAR(20) NOT NULL
>  email VARCHAR(40) NOT NULL
>  website VARCHAR(40) NOT NULL
>  interests TEXT(500) NOT NULL
>)
>  AUTO_INCREMENT = 100
>__________________________________________

Okay, so it's a file containing SQL, not a file containing just raw data
that you want to load.  That means you won't read it with LOAD DATA INFILE
as I was thinking earlier.

(Note that your statement should have a semicolon at the end, or it will
just be ignored.)

>
>First I changed profile.txt to member.txt; this is the text file I am trying
>to read.  Database is mycolors.  Table is member.
>
>1)   I tried  (within the mysql client):
>
>mysql> LOAD DATA LOCAL INFILE "member.txt" INTO TABLE member;
>
>but received this error message
>     ERROR: File 'member.txt' not found (Errcode: 2)

This isn't what you want since the file contains SQL rather than just
data.

>
>member.txt is  located  in C:\Apache\htdocs\mydirectory\member.txt
>but I'm not sure how to specify it so it will be found (Ref, Paul's book,
>page 566).

Although LOAD DATA isn't what you want, for future reference you can
use either doubled backslashes (\\) or slashes (/) on Windows to specify
filenames.  If you use backslashes, they must be doubled because backslash
is the MySQL escape character.

>
>
>2)  I tried at the prompt
>C:\>mysql mycolors < member.txt
>
>but received
>Bad command or file name

This means the directory containing the MySQL commands isn't listed in
your PATH variable.  Either modify PATH to contain that directory, or
specify the full pathname to the mysql program.  For example, if it's
in C:\mysql\bin, this might work:

C:\> C:\mysql\bin\mysql mycolors < member.txt

>
>  3)  I tried using mysqlimport, but also with no success.
>
>C:\>mysqlimport --local mycolors member.txt
>Bad command or file name

This is the same problem.


-- 
Paul DuBois, paul@stripped
Thread
Problem reading from a text fileMargie Wiers4 Apr
  • Re: Problem reading from a text filesinisa4 Apr
  • Re: Problem reading from a text filePaul DuBois4 Apr
  • Re: Problem reading from a text fileMargie Wiers4 Apr
    • Re: Problem reading from a text filePaul DuBois5 Apr
  • Re: Problem reading from a text fileMargie Wiers4 Apr
  • Re: Problem reading from a text fileSteve Ruby5 Apr
  • Re: Problem reading from a text fileSteve Ruby5 Apr
  • Re: Problem reading from a text fileMargie Wiers5 Apr
    • Re: Problem reading from a text filePaul DuBois5 Apr
    • Re: Problem reading from a text fileIan White5 Apr
  • Re: Problem reading from a text fileSteve Ruby5 Apr
  • Re: Problem reading from a text file -- solvedMargie Wiers5 Apr
RE: Problem reading from a text fileKeith Vance5 Apr