Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I recently created a database with one table in it. The table, in turn has three fields. Listed below are the characteristics of the fields:
Quote:
Field name Type Allow nulls? Key
Backup varchar(50) No Primary
TapeID varchar(20) No None
Description varchar(50) Yes None
I want to import into the database a csv file containing the pertinent information. An excerpt of the file is the following:
Quote:
LTO-4 RadOnc Servers DQH137L4 Radiation Oncology Servers
LTO-4 Research DQH141L4 Radiation Oncology Research Systems
LTO-4 Xio Systems DQH138L4 Xio Workstations
I ran a SQL command via the Webmin utility to import the csv file into the database, and there were no error messages displayed. However, when I try to view the data, there is none to be seen.
The version of MySQL that is being used here is 5.0.45. Does anyone have an idea as to why this is occurring, and how I can correct it? Thanks.
Actually, that is a semi-colon separated value file (and I think you meant csv, not cvs which is a version control system). Also, int's and double's wouldn't have quotes. A cvs, or comma separated value, file would look like:
A cvs (!), or comma separated value, file would look like:
What's that quote about correcting others for a mistake you also make
(do as I say, not as I do, iirc)
Anyway, to be serious:
@pliqui : show us a few lines of the actual(!) data file, the SQL cmd/msgs and use a desc cmd on the table.
If you had no errors(!), but no data appears, I'd say you used the wrong table name or schema (db) name.
chrism01, I guess typing cvs and csv so many times made my fingers confused (what's that thing about bedeg aale to rsed sasefkeig as ladg as tke fiast and ladt leasdrs are corsdesct?)
Anyway, pliqui isn't the one w/ the question or the csv (hey, I got it right that time) file, kaplan71 is. However, (s)he doesn't seem to be interested in the thread, so the entire exercise seems moot at this point.
Sorry about the delay in getting back to you all. I am definitely interested in the thread, so if I was not prompt in replying, it was completely accidental.
I was using a web interface to do the job, and that did not seem to work.
The next step was to try the command listed below:
Code:
load data local infile '/home/ahk/August2009-1.csv' into table offsite_archive
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
(Backup, TapeID, Description);
The end-result was the following:
Quote:
Failed to execute SQL : SQL load data local infile '/home/ahk/August2009-1.csv' into table offsite_archive fields terminated by ',' enclosed by '"' lines terminated by '\n' (Backup, TapeID, Description); failed : File '/home/ahk/August2009-1.csv' not found (Errcode: 2)
I am not readily with SQL commands, so I am guessing there is an error with my syntax.
Be aware that the filename is case sensitive. Further, because you're using local, the mysql client looks on the machine on which it's running for the file and it needs to be able to access it (permissions?).
Last edited by Wim Sturkenboom; 09-18-2009 at 11:02 AM.
I have made some progress. Once I changed the permissions on the file, I ran the commands again. This time, the first line of the file was imported into the database, but not the remaining lines.
Just to recap: The file is saved as a csv file, and can be opened within Microsoft Excel, or OpenOffice Spreadsheet. Any ideas? Thanks.
The lines might not be terminated by '\n'. So it reads the whole file as one line and there's only space for a limited number of fields and the rest is ignored.
Sorry i couldn't answer before but had some production problems.
I'm at home right now and don't have the desc of the table, but what i did was an export of the table with phpmyadmin and saved the file as csv. Phpmyadmin allows to change the paramater for the separator, so could be ',', ';','|', etc. the default one is ';'.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.