Comments (2)
Hi,
It affects both Reader and Writer.
When the struct_repr
parameter is set to pyorc.StructRepr.DICT
, then the Reader returns the rows as dicts and the Writer's write method expects a dict with all the keys of the column names. (It can have other keys that are not represented in the schema, but they will be ignored.)
import pyorc
input = open('./deps/examples/TestOrcFile.test1.orc', 'rb')
r = pyorc.Reader(input, struct_repr=pyorc.StructRepr.DICT)
print(next(r))
{'boolean1': False, 'byte1': 1, 'short1': 1024, 'int1': 65536, 'long1': 9223372036854775807, 'float1': 1.0, 'double1': -15.0, 'bytes1': b'\x00\x01\x02\x03\x04', 'string1': 'hi', 'middle': {'list': [{'int1': 1, 'string1': 'bye'}, {'int1': 2, 'string1': 'sigh'}]}, 'list': [{'int1': 3, 'string1': 'good'}, {'int1': 4, 'string1': 'bad'}], 'map': {}}
r = pyorc.Reader(input, struct_repr=pyorc.StructRepr.TUPLE)
print(next(r))
(False, 1, 1024, 65536, 9223372036854775807, 1.0, -15.0, b'\x00\x01\x02\x03\x04', 'hi', ([(1, 'bye'), (2, 'sigh')],), [(3, 'good'), (4, 'bad')], {})
output = open('test.orc', 'wb')
w = pyorc.Writer(output, 'struct<a:int,b:float,c:string>', struct_repr=pyorc.StructRepr.DICT)
w.write({'a': 1, 'b': 2.0, 'c': 'test'})
w.write({'a': 1, 'b': 2.0})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'c'
from pyorc.
great thanks a lot for the detailed and fast answer.
from pyorc.
Related Issues (20)
- How to edit the readme document? HOT 1
- Support for missing values in integer types HOT 2
- Installation on clean pypy3 environment fails: pybind11 missing HOT 5
- Reader can filter HOT 6
- pyorc.errors.ParseError: Footer is corrupt: types(1701470799) not exists HOT 2
- Invalid orc version
- Private Network Build HOT 2
- Possible to control filesize ? HOT 1
- Support for timestamp with local time zone HOT 2
- Add support to release Linux aarch64 wheels
- PyPI release for pyorc with orc v1.7.0 HOT 4
- set_metadata() casts to str() HOT 2
- Rec skips during sequencial reads HOT 2
- predicate to skip rows doesn't seem to work for timestamps HOT 6
- Apple Silicon Support? HOT 3
- can't find '__main__' module HOT 3
- orc Minimum is error? HOT 3
- Cannot install pyorc on Mac M1 HOT 2
- Please make python 3.11 wheels available from pypi HOT 1
- handle uniontype HOT 2
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 pyorc.