-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from dogversioning/main
Added python parquet tools, Sublime v3/4 updates
- Loading branch information
Showing
7 changed files
with
74 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.git* export-ignore | ||
/data export-ignore | ||
screencap.png export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,11 @@ ENV/ | |
.ropeproject | ||
|
||
# IDE | ||
.idea | ||
.idea | ||
|
||
#sample data | ||
.parquet | ||
.csv | ||
|
||
#input testing | ||
data/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
# sublime-parquet | ||
Reads Apache Parquet files in Sublime Text. The records are shown in JSON format, one JSON object per line. Parquet files are opened in read-only mode. | ||
Reads Apache Parquet files in Sublime Text using they python parquet-tools package. Files are rendered as CSVs. | ||
|
||
# Screenshot | ||
![screenshot](https://raw.github.com/yuj/sublime-parquet/master/screenshot.png) | ||
![screencap](https://raw.github.com/dogversioning/sublime-parquet-python/main/screencap.png) | ||
|
||
# Installation | ||
**via Package Control** | ||
|
||
1. Make sure you have [Package Control](https://packagecontrol.io/installation) installed. | ||
1. Open the Command Palette (`command-shift-P` on macOS; `ctrl-shift-P` on Ubuntu) and choose _Install Package_. | ||
1. Open the Command Palette (`command-shift-P` on macOS; `ctrl-shift-P` on Ubuntu/Windows) and choose _Install Package_. | ||
1. Choose _Parquet_ from the list. | ||
|
||
# Requirement | ||
This sublime package depends on the [parquet-tools](https://github.com/apache/parquet-mr/tree/master/parquet-tools) software. Make sure it is installed and on your PATH. | ||
|
||
On macOS (or Ubuntu), run ```brew install parquet-tools```. | ||
|
||
To install brew, visit http://brew.sh. | ||
# Requirements | ||
|
||
You'll need to have a python environment in your path, and then install [parquet-tools](https://github.com/ktrueda/parquet-tools) with `pip install parquet-tools`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import sublime | ||
import sublime_plugin | ||
|
||
import os | ||
import subprocess | ||
|
||
|
||
""" | ||
Parquet package for Sublime Text, with python tooling. | ||
https://github.com/yuj/sublime-parquet | ||
Requires the python port of parquet-tools | ||
https://github.com/ktrueda/parquet-tools | ||
""" | ||
|
||
|
||
COMMAND_NOT_FOUND_MSG = """'parquet-tools' not found.\n | ||
Make sure python is in your PATH and install with 'pip install parquet-tools' | ||
""" | ||
PYTHON_COMMAND_LINE = "parquet-tools csv {0}" | ||
UNICODE_ERROR = "Non-unicode characters prevented rendering: \n" | ||
|
||
|
||
def run_command(command): | ||
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
return iter(p.stdout.readline, b"") | ||
|
||
|
||
class ParquetCommand(sublime_plugin.TextCommand): | ||
def run(self, edit, filename=None): | ||
if filename is None or not filename.endswith(".parquet"): | ||
return | ||
command = PYTHON_COMMAND_LINE.format('"' + filename + '"') | ||
pos = 0 | ||
try: | ||
for line in run_command(command): | ||
row = line.decode("utf-8") | ||
pos += self.view.insert(edit, pos, row.rstrip() + "\n") | ||
except (UnicodeDecodeError, TypeError): | ||
self.view.set_name(os.path.basename(filename)) | ||
self.view.set_read_only(True) | ||
sublime.error_message(UNICODE_ERROR + str(line)) | ||
except (FileNotFoundError, AttributeError): | ||
sublime.error_message(COMMAND_NOT_FOUND_MSG) | ||
self.view.set_name(os.path.basename(filename)) | ||
self.view.set_read_only(True) | ||
|
||
|
||
class OpenParquetFile(sublime_plugin.EventListener): | ||
def on_load(self, view): | ||
filename = view.file_name() | ||
if filename.endswith(".parquet"): | ||
sublime.status_message("opening parquet file: " + filename) | ||
parquet_view = view.window().new_file() | ||
view.close() | ||
parquet_view.run_command("parquet", {"filename": filename}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.