Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining Numeric Field Widths #42

Closed
dennytron opened this issue May 6, 2013 · 4 comments
Closed

Defining Numeric Field Widths #42

dennytron opened this issue May 6, 2013 · 4 comments

Comments

@dennytron
Copy link

A great feature would be to define or read the width of numeric fields.

For example, specify an integer field in a dbf to be 10 digits wide or a double or float field to be a width of 12 digits and 6 decimals.

Thanks!
Dennis

@sgillies
Copy link
Member

sgillies commented May 7, 2013

Try this on for size:

{ 'code': 'int:10', 
  'length': 'float:12.6' }

Basically just like

>>> print("%10d" % 4)  
         4
>>> print("%12.6f" % 10.0)
   10.000000

Would that work? When reading, however, float precision would be lost unless we used Python decimals.

@dennytron
Copy link
Author

Hi Sean,

Yeah! That looks really nice and easy. When printing the schema of a dataset would it show { 'code': 'int:10', 'length': 'float:12.6' } ?

That looks great!

Dennis

@sgillies
Copy link
Member

sgillies commented May 8, 2013

Yep.

@sgillies
Copy link
Member

sgillies commented May 8, 2013

Fixed in 22c6165.

@sgillies sgillies closed this as completed May 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants