summaryrefslogtreecommitdiffstats
path: root/misc/file-processor-modules/preview.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:48:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:48:59 +0000
commitc484829272cd13a738e35412498e12f2c9a194ac (patch)
treea1f5ec09629ee895bd3963fa8820b45f2f4c574b /misc/file-processor-modules/preview.py
parentInitial commit. (diff)
downloadliborcus-upstream.tar.xz
liborcus-upstream.zip
Adding upstream version 0.19.2.upstream/0.19.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'misc/file-processor-modules/preview.py')
-rw-r--r--misc/file-processor-modules/preview.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/misc/file-processor-modules/preview.py b/misc/file-processor-modules/preview.py
new file mode 100644
index 0000000..244d8ce
--- /dev/null
+++ b/misc/file-processor-modules/preview.py
@@ -0,0 +1,33 @@
+########################################################################
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+########################################################################
+
+import orcus
+from orcus.tools.file_processor import config
+
+
+def process_document(filepath, doc):
+ buf = list()
+ for sh in doc.sheets:
+ try:
+ buf.append(f"sheet: {sh.name}")
+ for i, row in enumerate(sh.get_rows()):
+ if i > 9:
+ # Only display the first 10 rows.
+ buf.append("...")
+ break
+
+ row_s = list()
+ for cell in row:
+ v = cell.value if cell.value else ""
+ row_s.append(str(v))
+ row_s = ",".join(row_s)
+ buf.append(f"row {i}: {row_s}")
+ except Exception as e:
+ buf.append(f"???: (exception: {e})")
+
+ return buf