Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Import A Directory Of Text Files Into A Mysql Database With Php?


I have a directory of text files that i'd like to import into a msql
table... I was wondering if there's an easier way to do this with
php/mysql, I'd like to avoid copy/pasting the entire directory
(thousands of files) into the database if i can.

The directory structure of the text files resembles...

somepath/A/Aerosmith/Song Name.txt - (extention varies)

What i'd like to do is use php to scan the directory and input
the file path information and the content from each file into a table
like...

Dir Artist Song Text Type
------------------------------------------------------------------------
A Aerosmith Song Name Fa La La La La (example text) File Ext
B Beatles Song Name Fa La La La La (example text) File Ext




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Schedule Auto Import New Log / Text Files Into MySQL
Basically we have a SQL Server Database on our telecoms switch, to which under the maintenance contract we have no direct access. Every 15 mins log files are downloaded in *.log files (text files) which contain data we can upload to our own databases for querying. The log files are on an ftp server and the filenames comprise of date and time of dumps.

Requirement :

In short I would like to know the best way to automatically update tables on a MySQL database with the new log files as they appear or if there is some existing software which allows this type of schedule and auto import.

I would be very greatful if someone can give me some ideas with this problem as it would save me so much time and I am most familiar with mySql and Sql Server databases and would appreciate help in either database.

Import CSV, Text Files
how to automate the import of CSV, text files into MySql?

List Directory Files
Is there a command in mysql that could list directory files?

Loading Database From Multiple Text Files Each Containing A Partial List Of Columns
I'm kind of new to mysql. I would like to know if there is a way to use load infile or mysql import syntax to load one table with multiple files each containing a partial list of the table's columns:

Table contains : ID, first name, last name, occupation, salary

There are two files one containing the first three columns, the other the first field (ID) and last two fields. Is there a way to load them with just two load statements?

Note: I know that they can be loaded into two tables and later joined where ID is equal, but the actual example is about 30 text files rather than two, which is a bit too much.

Can't Import Dump Files In Mysql 5
I apologize upfront if this is common knowledge. I've searched for quite a while and found nothing concrete.

Using phpmyadmin 2.6.4-pl4
MySQL 4.0.23-nt
php 4.4.4

When I export and make a sql file, I cannot import the data using this setup:

phpmyadmin 2.6.4-pl4
MySQL 5.0.24a-community-nt
php 4.4.4


Get "No SQL query!" message through phpmyadmin when I import the .sql file. If I cut and paste out the create table or insert text it works, but that takes forever. If I copy the data files to the data folder everything works in mysql 5.

The sql files I've tried have been from 2-4 mbs. My backup dumps are 80 mbs though and obviously worried about restoring backups. Is there something I missed when upgrading? I pretty much copied off my data, uninstalled mysql 4 and installed mysql 5. Not in strict mode. Dataserver is in another location so can't always go copy the files off manually. Thanks for any help.

Which Is The Right Directory To Backup MySQL Database On Linux Opearing System?
Implemented web application using MySQL to maintain inventory of the
office PC's/laptops/Routers/hubs and other stuff, here we are using
MySQL as back-end Database on Linux Operating system. I need to backp
all these Inventory database into CD/Tape/Floppy, which is the right
directory (MySQL database) to backup (incase if the current MySQL
server crashes, then I should be able keep copy of my inventory),

MySQL Import Text File Too Big?
Our production database in an exported textfil runs about 60 MB.
Compressed that's about 9 MB.

I'm trying to import the export into another machine running FC3 and
mySQL 11.18, and it appears as though the file may be too big!
When I try to do it via command line:

mysql -u root --host=localhost printing < ./printing.txt

It eventually errors out with a "syntax error on line X" and only about
half the tables get imported, and MyPHPAdmin GUI interface says it has
a 2MB file limit on importing.

This concerns me. If something were to happen to our production
database, how am I going to restore it?

I tried to do a search on mysql.com, but that's a less than helpful
site for support. A newsgroup search on the topic didn't come up with
much, so maybe I'm just bad at using keywords.

Error In Mysql Import (text File)
Error

SQL query:

-- phpMyAdmin SQL Dump
-- version 2.8.0.2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 27, 2006 at 12:21 AM
-- Server version: 4.1.18
-- PHP Version: 4.4.2
--
-- Database: `lopata_trnew`
--
-- --------------------------------------------------------
--
-- Table structure for table `Register`
--
CREATE TABLE `Register` (
`id` int( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
`Date` date default NULL ,
`Name` text,
`Company` text,
`Address` text,
`City` text,
`State` tinytext,
`Zip` text,
`marketarea` text,
`Phone` text,
`Email` text,
`Comments` text,
`OwnerNameA1` text,
`OwnerNameB1` text,
`PropAddr1` text,
`PropZip1` text,
`OwnerNameA2` text,
`OwnerNameB2` text,
`PropAddr2` text,
`PropZip2` text,
`OwnerNameA3` text,
`OwnerNameB3` text,
`PropAddr3` text,
`PropZip3` text,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =49;

MySQL said: Documentation
#1064 - 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 '

CREATE TABLE `Register` (
`id` int(10) unsigned NOT NULL auto_increm' at line 1

Import Structured Text File Into Mysql
I've a lot of structured files like the following one I would like to import in a mysql database:

Message-ID: <417ee59f@mail-ha1>
Subject: test
From: renu [renu@solicomm.net]
Newsgroups: Practice

<html>
<head>

</head>
<body>
<p>
xghdgdfgfgdff
</p>
<p>
xgdsfssdfsdf
fsdfsfsdfhdgdfgfgdff
</p>
</body>
</html>

I need to import the first 4 rows in 4 columns (messageid, subject, form, newsgroups) and the last part of the text, which is in html, in a 5th colum.

The fact is that I'm not sure whether it's possible.
Should it be possible, could someone point me to the method/tool that could help me in doing that?

Import Data From Text File Mysql
Im going to write a script in linux that updates my mysql database. How can i write a sql statemtn that updates my mysql table from a text file located on my machine?
lil confused bout the path of the txt file?

Import Files
I am looking for solutions to autmatically import text files into MySQL. Something almost like a queue. Files will be dumped from one machine, to a directory. I then need the MySQL box (separate server) to pick up that file and import it into the MySQL database. I'm not sure how to do this, other than writing a script and scheduling it to check the directory periodically.

Import From Dump Files
I am trying to use a database in my dynamic web page setup but every time I try to restore a particular database in Mysql Administrator, I get the message
"The selected file was generated by mysqldump and cannot be restored by this application." I have read countless pages on this forum but even with the syntax generously provided I am still in trouble. I will provide some more detail to ensure I am not at fault with my syntax .

My database integrate.sql is in a folder for my downloaded files call it "downloads"
My Mysql setup in done in the default manner into the program files... path
My test local web site in a "integratewebsites" folder (in the windows default wwwroot folder of my c drive)

I want to restore the integrate.sql folder, I assume to the mysql default path (data) and point my web site there so I am not looking to move anything away from default locations. Can anybody help me with a sample command line please?

Import Multiple Files
I have 5 clients uploading structured .txt files into a directory. Every day, there are about 2000 text files uploaded.
I would like to import this textfiles every second with a cronjob.
How can i automate this import without having problems with the different "file_xxxx_0123.txt" filenames ?
How can i make the script select the oldest file in the directory

Change Database Directory
I have a linux server and i installed mysql . it's working fine.

But i want to change the mysql database dirctory from /var/lib/mysql
to /db/

how can i do that.

Change Database Directory
I have a linux server and i installed mysql . it's working fine.

But i want to change the mysql database dirctory from /var/lib/mysql
to /db/

how can i do that

Changing Database Directory Location
Is there any way to get MySQL to create the directory for a new database
in a specified directory instead of its "data" directory?

How To Create Database Not In A Default Directory
how to create database not on default directory.

Dropped A Database, But It's Still Showing Up In The Directory
I dropped a database used for practice. Although all the tables are gone, the empty database itself is still there. Is this correct? How do I get use of this empty db?

Note: I'm using Mysql version 3.23.49 -nt and I also use mysqlfront although I generally use the command line to work with the dbs.

Changing Database Directory Location
Is there any way to get MySQL to create the directory for a new database
in a specified directory instead of its "data" directory?

Move Database In Windows To Different Directory
How do I move a database on a Windows 2000 server box. I have MySQL and found where to point the database in the MY.ini file but I cant seem to move it to another partition. If I change the path in the my.ini file the mysql service fails to start. Any help would be greatly appreciated.

I have seen how to do this in unix and linux on this forum but could not find a thread on how to do it in Windows.

Cannot Start Database After Relocating The Data Directory
an error after I have relocated my data directory.I found the pid error-log file "bsd19.err" in the previous data directory and it wrote the following every time when I tried to start my database.

[Error]/usr/local/libexec/mysqld: Can't create/write to file: /usr/local/db2 (Errcode: 21)

[Error]Can't start server: can't create PID file: Is a Directory

I also have "chown" the user as mysql on that directory /usr/local/db2 before I start my database.

Text Files
Im doing perl for an online store and wondering if someone knew a way (a
script) to get my text files in to my database?

Importing Text Files.
I have an excel file... The first row in the excel file contains the names of fields in the MySQL database. (There are only four fields in my DB in a single table.) The following rows contain data that should be inserted into those fields. Well...

I can't figure out how to get that data from the excel file imported into the MySQL database. I have saved the excel file as a .csv file for testing purposes... On my web server I have phpMyAdmin installed...

It has a feature that says "import from text file"... However, whenever I try to import the csv file, it only grabs the first row (containg the field names) and part of the second row... When it grabs this data it puts it all into the first field in the DB... I can't figure out how to get it organized and get all of it inserted.

Loading Text Files
Im currently having problems loading a tab seprated file into mysql database.

It loads the data but with each field only loads half the data i.e. txt file contains "hello how are you world" (for a field) SQL table contains "hello how"
Not sure whats causing this as i've opened the same file in excel and it works perfectly (renamed it from .txt to .xls)

Importing Text Files
I'm importing our DOS data base (Dataflex) to Mysql I have a table with
174,638 records that I convert into a tab delimetered Text file however,
Mysql only reads 87,035!.

I checked the text file & it apperars fine is there
any limitation?

Import From Text
I have a text file which contains names and dates. the date is in the format
Sep-11-2001 12:30 AM.
I tried to put the text into Excel and then used Navicat to import from Excel.
But everytime the dates are converted to 1/1/2001.

Text Import
I need to append records from an Excel spreadsheet to an existing table. I think I should start by converted the Excel sheet to a text file then importing from there. I have to do this using myPHPAdmin. Am I on the right path and how do I start and import using myPHPAdmin?

60 Gb Of Mp4 Files In MySQL Database
I have a client who wants to store around 60 Gb of mp4 files for download on his website. Can MySQL store mp4 files? Would it be better to store all the videos in a zip file for bulk download also in a table in MySQL database?

How do I finish these tables to store Mp4 files and how do I create a table to store Mp4 files?

CREATE TABLE `mp4s` (
mp4ID INT(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`mp4s`)
)
ENGINE = MyISAM
CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `zipped_mp4s_courses` (
courseID INT(10) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`courseID`)
)
ENGINE = MyISAM
CHARACTER SET utf8 COLLATE utf8_general_ci;

Importing Data From Text Files
Can anyone show an example MySQL command to import a text file into a table?

I have a massive qty of data to get into a MySQL database on a server over
the internet. Shouldn't I be able to do this with a bulk operation instead
of a script with many tens of thousands of INSERT statements? I can deliver
each tables data as comma delimited text files.

Do I need to start with an empty MySQL table or can I import the text table
directly?

I am working with a remote Apache server using an ssh telnet jailshell
window. I have to ftp compressed files since the amount of data is large
and the uplink speed is slow.

Fixed Width Text Files
I need to import multiple fixed-width text files into a database on a daily basis. My thought was to do this with a stored procedure, but I don't see any mysql syntax that would allow me to load a fixed-width file into a table. What am I missing?

Importing Data From Text Files
Can anyone show an example MySQL command to import a text file into a table?

I have a massive qty of data to get into a MySQL database on a server over
the internet. Shouldn't I be able to do this with a bulk operation instead
of a script with many tens of thousands of INSERT statements? I can deliver
each tables data as comma delimited text files.

Do I need to start with an empty MySQL table or can I import the text table
directly?

I am working with a remote Apache server using an ssh telnet jailshell
window. I have to ftp compressed files since the amount of data is large
and the uplink speed is slow.

CSV Import When There Are Commas In The Text?
I'm trying to grab a csv file from a remote server and import the data my mySQL DB.

I'm using Curl to grab the file contents and php to import the data into my DB.

The problem have is that the data in the csv file contains commas in the text field that is interferring with the import and I have no control over what is in the file.

eg the csv looks like:

id,name,description1,description2,date
1,pete,"this has a comma, in the text", "this also has, a comma", 2004-09-09
etc, etc
The additional commas mess up the import. Is there any way I can get this data into mysql and just tell it to ignore any commas in certain fields?



How To Import Text File?
I am using MAMP and am trying to import a large text file (up to 30mb) that is defined by position i.e., space 1-8 = ID, space 9-14 = Description, etc. The only option for import is via SQL or CSV file.

Text File Import
I'm importing a large text file (8 million lines) into a mysql table via the heidisql front end. Each line has 42 fields (tab separated) so there's a lot of data to bring in.

I tested the import with a truncated version of the text file (10,000 lines) and the import worked fine. It took about a minute (i think) to import. Now though, the full version (which is 800x as long) has been importing for nearly 48 hours. Heidisql seems to be still working - it hasn't frozen, it's busy.

Is it normal for a file of this size to take so long to import?

Import A Text File
I have a utf8 txt file to import in a MySQL db, cause I must create a
web-application in PHP for reading this information on-line.
I have create a new DB in MYSQL 4.1.1a setting CHARACTER=utf8,
then I have create a table t1 with character set utf8 and some fileds
also with CHARACTER=utf8.
Then I imported the Txt file (really in UTF8 format, with 22600
records!) in my db. MySQL have imported the non-utf8 field correctly,
26000 records.
When I try to read this utf8 filed they appear like "???-?-???".
Then, also my PHP application show this field with stranges
characters. I have try also with PHPfunction utf8_encode with no
success

Import Text And Csv File
i want to import either text or csv file to database how can i do this..i have tried mysqlimport command but its giving some error

Importing Txt Files Into MySQL Database
For a long time I've been considering converting all the information on my homepage from php based to database based but I've always put it off because I have no idea how to go about doing this.

My main problem is that I have thousands of .txt files that have information like in this example that are imported into a webpage using php.

-----
homersimpson.txt

firstname=Homer
lastname=Simpson
maritalstatus=Married
relatives=Marge (wife), Bart (son), Lisa (daugter), Maggie (daughter)... etc
hometown=Springfield
-----

and so on. Sometimes the order in the files is different and "lastname=" comes before "firstname=" and so on which makes it practically impossible for me to turn the files into a tab or commaseparated files.

Now what I'm interested in knowing is whether or not there is a way for me to import such txt files into MySQL so that the first names, last names and so on go in the right tables? And if there is how is it done?

Importing A MySQL Database From .frm, .myi And .myd Files
I have the contents of a MySQL database sitting in a folder. Each file
in the folder is an ISAM table that is comprised of three files, its
..frm, .MYI and .MYD. I would like to import this database on another
MySQL installation running on another machine. I thought it would be
as simple as mysqladmin create <database_name> and then navigating to
the databases data directory and dropping in the ISAM files, however,
when I connect to the database using mysql I get "Didn't find any
fields in table <table_name>" for each of the 16 or so tables I tried
to copy over.

Import Of Database In Mysql
I get this error when I am importing the database. What am I doing
wrong?

ERROR 1064 at line 625735: You have an error in your SQL syntax near '
begin_excerpt varchar(250) default NULL,
PRIMARY KEY (id)
) TYPE=MyISAM' at line 5

What Database Do You Use To Import Into MySQL
I am setting up a MySQL database and find phpmyadmin very slow to enter data, so I am thinking of importing all the data from Microsoft Access 2003 instead. Or I could create a php page to enter the data.

What do you guys use as your main database to import into MySQL?

Import A Mysql Database
I have download a mysql database.
But I don't know how to impoet it to mysql server.

Import A Text Backup Of SQL Db Into Another One On Linux
I have a SQL file, which is a backup of a database (data+scheme).
The file was generated using MySQLGUI backup features on a windows 2k3 server.
Now I would like to import this data + scheme into a mysql server running on linux, there is no GUI on the machine.

2 questions if I may:

1. How do I import the described above data.
2. Will the meta data (permissions, collation & co.) will be restored as well, or will I need to reconfigure them ?

Data Import From Text File
When I try to import a text file with new data for an existing
table I get the error "1148 - the used command is not allowed
with this MySQL version."

I have tried with both PHPMyAdmin2.3 and with MySQLFront 2.5.
Both these GUI programmes have an "import from text file" command
which I have used successfully several times to add entries to
this table before - running just this MySQL version. I have
structured the data in the text file in just the same format as
previously.

Both these programmes are connecting to the database successfully
now and will display the contents of the existing table data and
strcutre of the database etc (despite an earlier connection
problem which seems to have been solved spontaneously).

But both now deliver exactly this error message (and therefore I
assume it is MySQL and not the interface programmes which is
doing it).I cannot see that I am doing anything different.

I have MySQL 4.0.12 on Windows ME PC with a local Apache server
and PHP.

What Naming Convention Does Mysql Use For Database Files? Where Does It Put Them?
I asked mysql to create a database named credifree (see below)
and later checked for filenames on the system like *credifree*
but I found nothing indicating that mysql created any filenames
like *credifree* - ideas as to why not?

From the captured screen-text below, you can see that the
credifree database does indeed exist...

mlh@appserver mlh $ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 4 to server version: 4.0.22

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> use credifree
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+------------------------+
| Tables_in_credifree |
+------------------------+
| paylog |
| secure_pdf |
| systemlog |
| tbiccreceiptsefx |
| tbiccreceiptsexp |
| tbiccreceiptstu |
| tbladdrchangesefx |
| tbladdrchangesexp |
| tbladdrchangestu |
| tbladdressesequifax |
| tbladdressesexperian |
| tbladdressestransunion |
| tblaftermath |
| tblbureaus |
| tblcfclientchanges |
| tblcfnegchanges |
| tblcr_types |
| tblcredifreeclients |
| tblcredifreenegs |
| tblcreditreports |
| tblhits |
| tblinboundtypes |
| tblinstructions |
| tblmemberlogins |
| tblmerchandise |
| tbloutboundtypes |
| tblprefixes |
| tblreasons |
| tblremoved |
| tblsales |
| tblsleepers |
| tblsuffixes |
+------------------------+
32 rows in set (0.00 sec)

mysql> select * from tblhits;
+------------+----------+
| DateHit | HitValue |
+------------+----------+
| 0000-00-00 | 79417 |
| 2004-09-30 | 76 |
| 2004-10-01 | 16 |
| 2004-10-04 | 11 |
| 2004-10-06 | 24 |
| 2004-10-07 | 20 |
| 2004-10-08 | 37 |
| 2004-10-10 | 9 |
| 2004-10-11 | 4 |
| 2004-10-12 | 19 |
| 2004-10-13 | 13 |
| 2004-10-14 | 7 |
| 2004-10-15 | 8 |
| 2004-10-16 | 30 |
| 2004-10-17 | 31 |
| 2004-10-18 | 26 |
| 2004-10-19 | 3 |
| 2004-10-21 | 9 |
| 2004-10-22 | 10 |
| 2004-10-23 | 5 |
| 2004-10-24 | 7 |
| 2004-10-25 | 21 |
| 2004-10-26 | 12 |
| 2004-10-27 | 4 |
| 2004-10-28 | 4 |
| 2004-10-29 | 7 |
| 2004-10-30 | 4 |
| 2004-10-31 | 20 |
| 2004-11-01 | 11 |
| 2004-11-02 | 4 |
| 2004-11-03 | 4 |
| 2004-11-04 | 7 |
| 2004-11-07 | 1 |
| 2004-11-08 | 18 |
| 2004-11-09 | 11 |
| 2004-11-10 | 38 |
| 2004-11-11 | 41 |
| 2004-11-13 | 1 |
| 2004-11-15 | 18 |
| 2004-11-16 | 11 |
| 2004-11-17 | 9 |
| 2004-11-18 | 7 |
+------------+----------+
42 rows in set (0.00 sec)

How Do I Move MySQL Database Files From Drive C: To D: ?
When we installed MySQL 5.0.45 (on Windows XP), we took the default installation directory specifications, which placed our MySQL instance's data files in:

C:Program FilesMySQLMySQL Server 5.0data

Our C: drive is full. We have 140 GB of free space on D:. We would like to relocate our MySQL "...data" directory onto the D: drive.

We have been unsuccessful in locating in the documentation how to make this happen.

Can someone please either"

1) direct me to a link in the doc to accomplish this or

2) post the steps we must follows to successfully relocate the contents of our "...data" directory from C: to D:?

Mysql Backed-up Database Files Deletion
how to delete the existing dump backed up files that were created using mysldump.bat ,

I am facing memoray /sotrage problems in my server due to the large size of these backups which happen on a daily basis. As of now I am deleting the older files manually?I hope there is a way for this in my sql?

Import .xls File Into A Mysql Database
I have a .xls file that i would like to import into a mysql database, I am ok creating the mysql table in phpmyadmin on my webspace but i cant work out or find any useful tutorials on how to import the database from the .xls format and get it into the database short of building a form and submitting by hand which would take far to long.



How Do I Import .csv File Into My Mysql Database?
I woould like to know how to import csv files into my mysql databse, I tried the:

LOAD DATA LOCAL INFILE '/importfile.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY ''

Commands but I dont know where would i put these command and wher do put the "importfile.csv", what directory and location?

Import Old Data To New Mysql Database
My machine was down before, fortunately I have back up the whole
/usr/local/mysql directory. Now I have setup a new mysql on a new
machine, how can I import the old data back to the new database??

My old mysql version: mysql-3.22.32
new mysql version: mysql-max-4.0.3-beta-sun-solaris2.7.sparc

I used to run the mysql like this:

/usr/local/mysql/bin/mysql abc

should I add the user abc to my new database first? and how?


Copyright © 2005-08 www.BigResource.com, All rights reserved