Comments (13)
I think, the problem here is that some users used this code to read the data and some others to write the data. So, what is ok for some ones are not ok to the others. I also can not writing the types B, F and T. I then use N with decimalcount != 0 to write doubles.
from php-xbase.
@letscape: I am trying to READ data from the cell.
from php-xbase.
Bug in file ...\src\XBase\Record.php, method Record.getObject, line 129:
case self::DBFFIELD_TYPE_NUMERIC:return $this->getInt($column->getName());
Type ('N') may be not only integer (in my case @'N33.4'): need analize this (length/decimalCount properties) and use getFloat/getDouble if it need.
Stuped quick-fix in Record.getInt may be something like that (for debug purposes only!):
// return intval($s);
if (($res = intval($s)) != $s) {
$res = doubleval($s);
}
return $res;
p.s. this bug probably is not connected with @root-talis problem - at the not corrected version get 8.0 at the both rows of the table...
from php-xbase.
See my pull request for more correct desigion.
from php-xbase.
Great, thanks for that. I'm really short on time right now, so I hadn't had a chance to look at this issue.
from php-xbase.
There are another problem when we try to write a dbf here: https://github.com/hisamu/php-xbase/blob/master/src/XBase/Record.php#L295
Is caused by:
$this->table->getColumn($columnName)
because of this:
https://github.com/hisamu/php-xbase/blob/master/src/XBase/Table.php#L233
The code create an intermediate table (a writableTable) inside the writableTable to write the dbf and is complex to see that the condition can not be satisfy in one of them: https://github.com/hisamu/php-xbase/blob/master/src/XBase/WritableTable.php#L49
Simple fix:
public function setObjectByName($columnName, $value)
{
if(array_key_exists($columnName, $this->table->getColumns()))
return $this->setObject($this->table->getColumn($columnName), $value);
}
from php-xbase.
This iteration is also inefficient:
https://github.com/hisamu/php-xbase/blob/master/src/XBase/Table.php#L225-L231
but yes is working...
from php-xbase.
Simple fix:
But this is masking problem and this is no good: if the field not found this is a error in client's code - exception need to be thrown (as is) for handling by the caller code - not silent.
from php-xbase.
@wardopdem true, that's why i don't opened a pull request.
from php-xbase.
@lestcape is this fixed now? I am getting same error from dev-master
from php-xbase.
@cerw I don't know, my solution was implement a python script (using a python dbf library) to migrate data to an special type of csv where columns headers contains the type and size(like they are display in libreoffice), then I call the script from php to do what i want (read or write data from/to the special csv). As a result, i have support for encoding data automatically. My dbf also can be read by default with VisualFoxPro, without asking for a charset or say that my dbf data is corrupted.
from php-xbase.
I'm trying to simplify my solution, migrating a probed Python library that works. Who want to help is here: https://github.com/lestcape/DbfPHP
from php-xbase.
I don't think it's still relevant
from php-xbase.
Related Issues (20)
- language not supported HOT 2
- 'tests' directory in reposit ( zip file) HOT 2
- HOW TO ADD NEW COLUMN HOT 2
- Compatible .dbf versions HOT 1
- Save inside a temp file HOT 8
- PHP Fatal error: Uncaught LogicException: Invalid number of bytes in binary string HOT 6
- Can't read or edit data from any dbf files, nor adding new records HOT 3
- TableException: Expected header terminator not present at position 6049 HOT 9
- Uncaught TypeError: str_pad() expects parameter 1 to be string, bool given HOT 1
- Invalid number of bytes in binary string. Expected: 123. Actual: 124 HOT 1
- .fpt file disappears when appending record to .dbf file HOT 5
- Creating Visual FoxPro files results in an incorrect Header Length HOT 1
- Fatal Error reading Foxpro dbf HOT 1
- Failed to open stream: Permission denied (disappearing .fpt that is not regenerated) HOT 1
- Memo is null
- Cannot use Y column type HOT 1
- Cannot read Floating Point vairable
- Encoding or Language ID HOT 1
- Float and Double Type is not support how need to create column ?
- writeRecord() changes all decimal digits in the record HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-xbase.