Jump to content

Importing Txt files into a database


BoneHunter9

Recommended Posts

First,im a kinda noob with mysql,i know some basics,not more.

Thats the reason for my following question:

 

I have a giant .txt file with many user datas in,but now i need all these datas in a sql database.

The database contains a table called "Plots" with the following rows: idx ; idz ; owner ; topX ; topZ

So the format of the datas in the txt file is that:

 

 

        max: {x: 127.0, y: 200.0, z: 208.0}
            user: [maximini97]
 
I marked with colors wich data has to be in what row.
The row idx and idz just has to be continued in that style: -1;-2 etc
 
I have about 2000 datas to put in,and doing this by hand would be a fulltime job.
So i need a sql command or a script for this.
I would be very happy when someone can help me with this :)
 
Greetings
Bone
Link to comment
https://forums.phpfreaks.com/topic/276576-importing-txt-files-into-a-database/
Share on other sites

If you want to have a crack at this yourself, then you need to read up on a bit of stuff.

 

Firstly, start with basic PHP syntax, if you haven't done so already. Then, move on to the next chapters of the PHP manual, skipping the installation one (as PHP is installed already).

I recommend reading everything up to the function reference, which you'll be using as a... Well, reference, later on. ;)

 

Once you've done that, you'll want to find a MySQL + PHP tutorial, which there are many of. Just take care to preferably find one that is using MySQLI or PDO, since the others are out of date by now. Follow it, to get a basic understand of how SQL works.

Also, remember to read up on SQL injections, and how to protect you against them. Hint: Prepared statements.

 

The next step is to read up on JSON, and how to decode JSON in PHP. Along with reading files, and that should be all of the basic functionality you need.

 

Good luck!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.