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
Share on other sites

I figured out that i need a script,so i hoped to find someone here who can help me out with that.

And this needs only to do 1 time,after that i dont need the txt file anymore :S 

So setting up a freelance announcement is mabye to mutch 

Edited by BoneHunter9
Link to comment
Share on other sites

We will help you with code YOU write, or you can hire someone to do it for you.

 

What have you done so far? Cause so far you're saying "help me out" but it's looking like "do it for me".

Edited by Jessica
Link to comment
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!

Edited by Christian F.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.