![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to insert data into MYSql database from a text file | shirleyeow | Shell Programming and Scripting | 4 | 01-11-2008 01:00 AM |
| Extracting data from text file based on configuration set in config file | suparnbector | Shell Programming and Scripting | 3 | 08-09-2007 11:25 PM |
| Need Shell Script to upload data from Text file to Oracle database | chandrashekharj | Shell Programming and Scripting | 6 | 03-26-2007 12:21 AM |
| insert text into top of file | jimbob | Shell Programming and Scripting | 1 | 09-22-2006 02:46 PM |
| SED- Insert text at top of file | MBGPS | Shell Programming and Scripting | 12 | 07-03-2002 06:48 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
how to insert data in database based on text file?
Hi....can you guys help me out in this script??
Below is a text file script....called Bukom.txt and it contains these: BUKOM 20060101 2.5 2.6 2.7 2.8 2.9 2.3 2.1 BUKOM 20060102 2.4 2.5 2.6 2.7 2.7 2.6 2.4 BUKOM 20060103 2.1 2.3 2.5 2.6 2.7 2.7 2.6 I would like this set of data to be auto read by the script to be insert into the database. The database table is call bukom_table and its contains 4 fields..namely: locn, date, hour, strength.. How to create a script that insert this data into the database? for example bukom will be in locn...and i do not want anyspace behind. and for the date will be 20060101 and the strength will be 2.5. ok for the fields hour it will have to create manually...like for first row..2.5 is the strength and 0000 will be hour..follow by 2.6 will be 0030 hour and 2.7 will be 0100 hour. likewise for the second row...2.4 will be 0000 hour and 2.5 will be 0030 hour and so on... im having a headache now on working on this scripts....hope you(expertists) can help |
| Forum Sponsor | ||
|
|
|
|||
|
Make a new formatted file
You can write code to create the formmated data you want and write it to a csv file. The format of the csv files should be:
field1,field2,field3,field4 You should then need a corresponding ctl file containg the column names in a comma separated format. Then you can have a shell script calling the sqlldr which can use the data and ctl files. Regards, Rahul. |
|
|||
|
And however large the mount of data maybe there are many options in sqlldr to load it into the DB in less than a minute. Just take care that the table u r inserting data into does not have any indexes created on them.
|
|
|||
|
i got over thousands of data and its hard for me to format all into the correct fields....i need a script to auto read it as there are more than 8 files to read from.......above are my problems....as you see the hour field needed to be inserted manually..i will need days to insert it as the records are too much...
|
|
|||
|
You can with mysqlimport
Quote:
mysqlimport --fields-terminated-by=" " your_database Bukom.txt |
|||
| Google The UNIX and Linux Forums |