Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
646dc69a
Commit
646dc69a
authored
Jan 31, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
example plugin to read a spreadsheet attached in the json ( with Input_viewAttachDocument )
parent
0303aa51
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
953 additions
and
0 deletions
+953
-0
dream/plugins/ExampleReadAttachedSpreadsheet.py
dream/plugins/ExampleReadAttachedSpreadsheet.py
+29
-0
dream/simulation/Examples/example_attach_document.json
dream/simulation/Examples/example_attach_document.json
+924
-0
No files found.
dream/plugins/ExampleReadAttachedSpreadsheet.py
0 → 100644
View file @
646dc69a
from
copy
import
copy
import
json
import
time
import
random
import
operator
import
StringIO
import
xlrd
from
dream.plugins
import
plugin
class
ExampleReadAttachedSpreadsheet
(
plugin
.
OutputPreparationPlugin
):
""" Example on how to read an excel spreadsheet
"""
def
preprocess
(
self
,
data
):
""" Example showing how to read an attached file
"""
# Attachement is encoded in data uri, ie data:application/excel;base64,***
data_uri_encoded_input_data
=
data
[
'input'
][
self
.
configuration_dict
[
'input_id'
]]
mime_type
,
attachement_data
=
data_uri_encoded_input_data
[
len
(
'data:'
):].
split
(
';base64,'
,
1
)
attachement_data
=
attachement_data
.
decode
(
'base64'
)
workbook
=
xlrd
.
open_workbook
(
file_contents
=
attachement_data
)
print
"This spreadsheet contains sheets:"
,
workbook
.
sheet_names
()
raise
ValueError
(
workbook
.
sheet_names
())
return
data
\ No newline at end of file
dream/simulation/Examples/example_attach_document.json
0 → 100644
View file @
646dc69a
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment