nchizhov / inok-dbf

Package for reading DBASE-files (FoxPro) wuth/without MEMO-fields
MIT License
9 stars 3 forks source link

Issue with memo fields getting truncated (first character missing, multiple lines not being included) #2

Open jpk32 opened 6 years ago

jpk32 commented 6 years ago

Hi,

I'm running into an issue getting the full (and complete) contents of a Visual FoxPro memo field to populate correctly. When I use tools such as DBF Commander, the 'acctref' field is populated, so I do not believe this to be database corruption.

Here are the headers from the table: [dbf_file] => /mnt/[retracted]/colacct.DBF [table] => colacct [version] => 48 [date] => 18.10.2017 [records] => 367588 [record_length] => 690 [unfinish_transaction] => 0 [coded] => 0 [mdx_flag] => 3 [charset] => 3 [charset_name] => cp1252 [memo] => 1 [columns] => 88 [memo_file] => /mnt/[retracted]/colacct.fpt [version_name] => Visual FoxPro with memo-fields

Here is an example: ["acctref"]=> "ROCEDURE CODE/DESC/AMOUNT: 4589 MANAGED CARE WITHHOL / -1.03 / H MEDICAL CEN /

The correct entry is: PROCEDURE CODE/DESC/AMOUNT: 4589 MANAGED CARE WITHHOL / -1.03

As you can see, the ' / M MEDICAL CEN /' portion of the line is missing, as well as about 10 text entries above this line in the same memo entry.

Here is a dump of the $memo variable within readMemo(): Array ( [signature] => text [length] => 2703 )

nchizhov commented 6 years ago

May you attach dbf and memo-files with sample (5-10 records)?

jpk32 commented 6 years ago

Hi,

Thanks for the quick response. I would love to but these files contain PII so I cannot attach them. Are there any additions or debugging I could add that would assist you otherwise?

nchizhov commented 6 years ago

May you take me field descriptions? $table->getColumns() And say, what version of Visual Fox Pro are you using?

jpk32 commented 6 years ago

Sure: Array ( [0] => Array ( [name] => acctno [type] => C [length] => 6 [decimal] => 0 [flag] => 0 [system] => [has_null] => [binary] => [auto_increment] => )

[1] => Array
    (
        [name] => dbtrno
        [type] => C
        [length] => 6
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[2] => Array
    (
        [name] => actcat
        [type] => C
        [length] => 10
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[3] => Array
    (
        [name] => aclntno
        [type] => C
        [length] => 5
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[4] => Array
    (
        [name] => clnt_ref
        [type] => C
        [length] => 26
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[5] => Array
    (
        [name] => asigndt
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[6] => Array
    (
        [name] => accandt
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[7] => Array
    (
        [name] => lstpydt
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[8] => Array
    (
        [name] => lstpyam
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[9] => Array
    (
        [name] => lstindt
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[10] => Array
    (
        [name] => acprndt
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[11] => Array
    (
        [name] => actprin
        [type] => N
        [length] => 11
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[12] => Array
    (
        [name] => aclegfee
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[13] => Array
    (
        [name] => att_fee
        [type] => N
        [length] => 9
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[14] => Array
    (
        [name] => acagcyfe
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[15] => Array
    (
        [name] => acckfee
        [type] => N
        [length] => 8
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[16] => Array
    (
        [name] => acintam
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[17] => Array
    (
        [name] => actotal
        [type] => N
        [length] => 11
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[18] => Array
    (
        [name] => sales_tax
        [type] => N
        [length] => 7
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[19] => Array
    (
        [name] => guarantor
        [type] => C
        [length] => 26
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[20] => Array
    (
        [name] => accomm
        [type] => N
        [length] => 7
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[21] => Array
    (
        [name] => acintrt
        [type] => N
        [length] => 6
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[22] => Array
    (
        [name] => com_name
        [type] => C
        [length] => 4
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[23] => Array
    (
        [name] => collno
        [type] => C
        [length] => 3
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[24] => Array
    (
        [name] => acstat
        [type] => C
        [length] => 6
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[25] => Array
    (
        [name] => acctdsp
        [type] => L
        [length] => 1
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[26] => Array
    (
        [name] => actfwd
        [type] => C
        [length] => 16
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[27] => Array
    (
        [name] => fwd_date
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[28] => Array
    (
        [name] => fwdcomm
        [type] => N
        [length] => 6
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[29] => Array
    (
        [name] => actfrm
        [type] => C
        [length] => 26
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[30] => Array
    (
        [name] => nxtldate
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[31] => Array
    (
        [name] => nxtltype
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[32] => Array
    (
        [name] => briefref
        [type] => C
        [length] => 16
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[33] => Array
    (
        [name] => lstldate
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[34] => Array
    (
        [name] => lstltype
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[35] => Array
    (
        [name] => sort_pri
        [type] => C
        [length] => 1
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[36] => Array
    (
        [name] => batch
        [type] => C
        [length] => 6
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[37] => Array
    (
        [name] => acct_data
        [type] => C
        [length] => 10
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[38] => Array
    (
        [name] => acctref
        [type] => M
        [length] => 4
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[39] => Array
    (
        [name] => bank
        [type] => C
        [length] => 26
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[40] => Array
    (
        [name] => chk_date
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[41] => Array
    (
        [name] => chk_no
        [type] => C
        [length] => 6
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[42] => Array
    (
        [name] => b_acct_no
        [type] => C
        [length] => 16
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[43] => Array
    (
        [name] => cb_rep_in
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[44] => Array
    (
        [name] => cb_rep_out
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[45] => Array
    (
        [name] => cb_acct_tp
        [type] => C
        [length] => 1
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[46] => Array
    (
        [name] => prom_start
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[47] => Array
    (
        [name] => prom_freq
        [type] => N
        [length] => 3
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[48] => Array
    (
        [name] => prom_amt
        [type] => N
        [length] => 8
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[49] => Array
    (
        [name] => prom_bkn
        [type] => N
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[50] => Array
    (
        [name] => prom_act
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[51] => Array
    (
        [name] => prom_cont
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[52] => Array
    (
        [name] => late_fee
        [type] => N
        [length] => 7
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[53] => Array
    (
        [name] => last_mod
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[54] => Array
    (
        [name] => mod_init
        [type] => C
        [length] => 3
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[55] => Array
    (
        [name] => attorney
        [type] => C
        [length] => 4
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[56] => Array
    (
        [name] => att_pct
        [type] => N
        [length] => 5
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[57] => Array
    (
        [name] => j_date
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[58] => Array
    (
        [name] => int_acct
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[59] => Array
    (
        [name] => admin_no
        [type] => C
        [length] => 3
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[60] => Array
    (
        [name] => admindate
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[61] => Array
    (
        [name] => lastjdate
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[62] => Array
    (
        [name] => comment_cb
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[63] => Array
    (
        [name] => status_cb
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[64] => Array
    (
        [name] => bank_micr
        [type] => C
        [length] => 10
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[65] => Array
    (
        [name] => in_use
        [type] => C
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[66] => Array
    (
        [name] => date_del
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[67] => Array
    (
        [name] => sm_action
        [type] => C
        [length] => 3
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[68] => Array
    (
        [name] => sm_status
        [type] => C
        [length] => 1
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[69] => Array
    (
        [name] => clgroup
        [type] => C
        [length] => 6
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[70] => Array
    (
        [name] => guarantee
        [type] => L
        [length] => 1
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[71] => Array
    (
        [name] => guar_date
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[72] => Array
    (
        [name] => guar_amt
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[73] => Array
    (
        [name] => gpaid_date
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[74] => Array
    (
        [name] => nsf_reason
        [type] => C
        [length] => 15
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[75] => Array
    (
        [name] => acmisc1
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[76] => Array
    (
        [name] => acmisc2
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[77] => Array
    (
        [name] => acmisc3
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[78] => Array
    (
        [name] => guar_pdamt
        [type] => N
        [length] => 10
        [decimal] => 2
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[79] => Array
    (
        [name] => cvrpt_in
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[80] => Array
    (
        [name] => cvrpt_out
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[81] => Array
    (
        [name] => guar_rej
        [type] => C
        [length] => 15
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[82] => Array
    (
        [name] => intstart
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[83] => Array
    (
        [name] => cc_date
        [type] => D
        [length] => 8
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[84] => Array
    (
        [name] => verifid
        [type] => C
        [length] => 10
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[85] => Array
    (
        [name] => cii_code
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[86] => Array
    (
        [name] => cc_code
        [type] => C
        [length] => 2
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

[87] => Array
    (
        [name] => stat_lock
        [type] => L
        [length] => 1
        [decimal] => 0
        [flag] => 0
        [system] => 
        [has_null] => 
        [binary] => 
        [auto_increment] => 
    )

)

Sadly, this application is from a vendor that won't provide us with the version of FoxPro they compiled their program with. The version as detected by inok-dbf is '48' (Visual FoxPro with memo-fields)

From reviewing the output of 'strings' on the compiled application, it looks like Visual FoxPro 9

jpk32 commented 6 years ago

Hi,

I think I figured this out. The line breaks in the memo blocks were just carriage returns (\r). I replaced "\r\n" in the str_replace() function with "\r" and the seems to have corrected the problem.