/    Sign up×
Community /Pin to ProfileBookmark

help with a dbf file

I’m exporting data from a dbf file so I can store it in mysql. The dbf file I’m using uses a “referenceID” column as the unique key for entries, however, for what I need to do I need to exclude certain referenceID’s. The ones I need to exclude have an * in front of the ID, the issue I’m having is when I grab the data using dbase_get_record_with_names(), it doesn’t display the * before the referenceID so i have no way to run an exclusion script as it doesn’t appear to be grabbing the * along with the ID.

As far as I can tell it’s not another column, as nothing shows up when I grab the DB header details. Is there something I’m missing to be able to exclude all that have an *? Or is my best solution to just open the dbf file (using fopen), remove all the * entries and then do my dbase functions?

Thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@rootDec 03.2014 — 
  • 1. You don't say what database file it is, is it a Flatfile CSV, SQLite, MSAccess, Foxpro ..?

    It does help to know what the original file type is.


  • 2. Example of the code you have written to perform the porting to another format, for all you and we know the problem may only be in your code and not showing what you have done is like shooting in the dark to hit the target.
  • Copy linkTweet thisAlerts:
    @CharlesDec 06.2014 — I actually read quite a lot of DBASE files, the attribute tables in GIS shape files are DBASE and I do a lot with GIS. On the Windows I've never had a problem reading them with PHP Data Objects ( http://php.net/manual/en/book.pdo.php ) or ODBC ( http://php.net/manual/en/book.uodbc.php ) by connecting trough the Jet. But you'll need the connection string ( http://www.connectionstrings.com/dbf-foxpro/ ).
    Copy linkTweet thisAlerts:
    @GenixdeaeauthorDec 06.2014 — I apologize for the long delay in the response, been busy with work.

    for .

    1) It's a .dbf file, unfortunately it's through a program our company uses so I don't know how exactly they are creating the file. If it helps, there is one other file with this one, it is a .cdx (so I'm guessing it's FoxPro).

    2)Here's my code[code=php]$db = dbase_open('data.dbf', 0); //Connect to file read-only
    $num_records = dbase_numrecords($db); //Count the records
    $limit = ($num_records - 200); //Only need the last couple hundred for testing
    for($i = 1; $i <= $num_records; $i++) {
    $record = dbase_get_record_with_names($db, $i);
    echo 'Booking Ref: '. $record['BOOKINGREF']; //Output record
    }[/code]

    OUTPUT (as an example): Booking Ref in the files displays as: *2D3023885485

    Script returns: 2D3023885485

    I need the entries with *
    's not to be processed because they are cancelled/deleted entries

    Charles: I've never used PDO for anything except MySQL so thanks for the info. It may save me a step of converting it, though I think I'd have the same issue I am at the moment.
    Copy linkTweet thisAlerts:
    @rootDec 06.2014 — A search for dbase_open returns the information that you are using a dBase database.

    http://php.net/manual/en/function.dbase-open.php

    You may find your answer on the PHP site!!
    ×

    Success!

    Help @Genixdeae spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...