Go Back   CodingForums.com > :: Server side development > MySQL > Other Databases

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-23-2013, 05:34 PM   PM User | #1
jnt
New Coder

 
Join Date: Mar 2011
Location: Underworld
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
jnt is an unknown quantity at this point
DBF database questions

I have some old database (from app that worked under DOS), and now i have to convert it to some modern format (MySQL). Format of database is FoxBase+/dBase III PLUS (extension is DBF). I found some software and converted it to MySQL, BUT...

In some columns, fields look like this:

Code:
$aSomeGuyName$fAdress
Sometime there is more $a (or any other letter), sometimes less.

If i make a query on this database, i get only:

Quote:
$aSomeGuyName$fAdress
Is there some way to "use" this $a things with PHP/MySQL or i have to remove it all (there is thousands of records in database).
jnt is offline   Reply With Quote
Old 01-24-2013, 07:36 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,211
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
In MySQL, you can put BACK TICKS (the ` character, usually on the same keyboard key as the ~ tilde character) around any string to make it a valid column name.

So, for example, you would write:
Code:
SELECT * FROM sometable WHERE `$aSomeGuyName$fAdress` LIKE 'John%'
Note carefully the difference between back ticks and apostrophes. It's hard to see, so make sure you use the right characters.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Old 01-24-2013, 07:39 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,211
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
If you mean that the *CONTENT* of the field is $aSomeGuyName$fAdress, then I would say the conversion program, converting from DBF to MySQL, messed up.

Somehow, it shoved two or more field values into a single field.

If the pattern is *consistent* for all records with that particular field, then we could probably figure out how to use MySQL to clean up the data. If it is not consistent, if it only happens in some records and not in others, then you'll probably need to use PHP to decode it.

If you could give some *REAL* examples, we might be able to help.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Old 01-25-2013, 10:01 PM   PM User | #4
jnt
New Coder

 
Join Date: Mar 2011
Location: Underworld
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
jnt is an unknown quantity at this point
Well here is examle (all fields are like this):

Code:
insert into tablename values('22000','886.2-32','3796','$aS0mename$fOtherName$eSomethingElse','','','1699','$d2006','$a117 str.$d22 cm','$aBlahBlah','','ISBN 953-178-726-3','821.163.42-32','1','','T','0','0','D','BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah','','22.08.2006','T','F','F','','ABCDEF','','GITA4','','','T','');
Ofc, i manage to make valid columns outh of this, but there is still problem with $aSomething. It is everywhere (pattern is consistent). Mybe you can help the fact that this base is used by some old program that worked under DOS.
jnt is offline   Reply With Quote
Old 01-26-2013, 03:04 AM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,211
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Do you still have dBase 3 or equivalent? Can you look at the data and see what it *SHOULD* be?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Old 01-26-2013, 09:30 AM   PM User | #6
jnt
New Coder

 
Join Date: Mar 2011
Location: Underworld
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
jnt is an unknown quantity at this point
Yes, it is like in this example, but i want to remove this $ things and insert values i get in different columns. Or to do something better with that (but as i can see, $ does not have some useful purpose).
jnt is offline   Reply With Quote
Old 01-28-2013, 04:19 AM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,211
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
*SIGH* I should have been more explicit.

I meant: Can you SHOW US a few records from the dBase3 database? What they looked like there? And then show us the same records as that tool changed them to MySQL?
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Old 01-28-2013, 09:08 AM   PM User | #8
jnt
New Coder

 
Join Date: Mar 2011
Location: Underworld
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
jnt is an unknown quantity at this point
Yes i can, but i didn't because they are the same. Here it is dbf:

http://prntscr.com/qp985

and when isnerted in mysql:

http://prntscr.com/qpakr
jnt is offline   Reply With Quote
Old 01-28-2013, 09:32 PM   PM User | #9
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,211
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ahhh...

I am going to *GUESS* that those are NON-ASCII characters and that the $XX stuff you are seeing if dBase's way of representing non-ASCII.

But that is not the only problem, as I can see by looking at that dump.

I *think* you need to find a copy of dBase that is localized to your language. It looks to me like the version you have there is for ASCII/English and is not working right for your language. Sorry, but I have no idea how to change those codes in MySQL, once they are imported wrongly.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote
Users who have thanked Old Pedant for this post:
jnt (01-29-2013)
Old 01-29-2013, 08:47 AM   PM User | #10
jnt
New Coder

 
Join Date: Mar 2011
Location: Underworld
Posts: 15
Thanks: 6
Thanked 0 Times in 0 Posts
jnt is an unknown quantity at this point
Tnx for your reply. I fixed problem with ASCII characters (i replaced ascii signs with real characters), but there is still $stuff problem. I think that is some "rules" that was within DOS program that used this database. I will try to get problematic columns exploded in PHP and then inserted in new base (or something like that).
jnt is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:41 PM.


Advertisement
Log in to turn off these ads.