From df938dc98e5538e8cebfb4e5ccaef6c0fcbdc8ba Mon Sep 17 00:00:00 2001 From: Jay Clifford Date: Tue, 11 Jul 2023 13:40:49 +0100 Subject: [PATCH 1/2] Removed ORC support for windows --- influxdb_client_3/read_file.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/influxdb_client_3/read_file.py b/influxdb_client_3/read_file.py index dcecf75..74b6f63 100644 --- a/influxdb_client_3/read_file.py +++ b/influxdb_client_3/read_file.py @@ -2,7 +2,6 @@ import pyarrow.csv as csv import pyarrow.feather as feather import pyarrow.parquet as parquet -import pyarrow.orc as orc import pandas as pd class upload_file: @@ -19,8 +18,6 @@ def load_file(self): return self.load_csv(self._file) elif self._file.endswith(".json"): return self.load_json(self._file) - elif self._file.endswith(".orc"): - return self.load_orc(self._file) else: raise ValueError("Unsupported file type") @@ -32,9 +29,7 @@ def load_parquet(self, file): def load_csv(self, file): return csv.read_csv(file, **self._kwargs) - - def load_orc(self, file): - return orc.read_table(file, **self._kwargs) + #TODO: Use pyarrow.json.read_json() instead of pandas.read_json() def load_json(self, file): From fe5b68969b5bdb968df3e70f83a5ce92d1cc9c47 Mon Sep 17 00:00:00 2001 From: Jay Clifford Date: Tue, 11 Jul 2023 14:05:10 +0100 Subject: [PATCH 2/2] added windows omit --- Examples/file-import/orc_write.py | 4 ++-- influxdb_client_3/__init__.py | 4 +++- influxdb_client_3/read_file.py | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Examples/file-import/orc_write.py b/Examples/file-import/orc_write.py index 18ae7f5..a4ae04d 100644 --- a/Examples/file-import/orc_write.py +++ b/Examples/file-import/orc_write.py @@ -1,7 +1,7 @@ import influxdb_client_3 as InfluxDBClient3 import pandas as pd import numpy as np -from influxdb_client_3 import write_client_options, WritePrecision, WriteOptions, InfluxDBError +from influxdb_client_3 import write_client_options, WriteOptions, InfluxDBError class BatchingCallback(object): @@ -35,7 +35,7 @@ def retry(self, conf, data: str, exception: InfluxDBError): token="INSERT_TOKEN", host="eu-central-1-1.aws.cloud2.influxdata.com", org="6a841c0c08328fb1", - database="python", _write_client_options=wco) as client: + database="python") as client: diff --git a/influxdb_client_3/__init__.py b/influxdb_client_3/__init__.py index bc1943e..530a4d2 100644 --- a/influxdb_client_3/__init__.py +++ b/influxdb_client_3/__init__.py @@ -12,6 +12,8 @@ def write_client_options(**kwargs): return kwargs +def default_client_options(**kwargs): + return kwargs def flight_client_options(**kwargs): return kwargs # You can replace this with a specific data structure if needed @@ -45,7 +47,7 @@ def __init__( """ self._org = org self._database = database - self._write_client_options = write_client_options or write_client_options(write_options=SYNCHRONOUS) + self._write_client_options = write_client_options if write_client_options is not None else default_client_options(write_options=SYNCHRONOUS) # Extracting the hostname from URL if provided parsed_url = urllib.parse.urlparse(host) diff --git a/influxdb_client_3/read_file.py b/influxdb_client_3/read_file.py index 74b6f63..a67f257 100644 --- a/influxdb_client_3/read_file.py +++ b/influxdb_client_3/read_file.py @@ -2,6 +2,12 @@ import pyarrow.csv as csv import pyarrow.feather as feather import pyarrow.parquet as parquet +import os + +# Check if the OS is not Windows +if os.name != 'nt': + import pyarrow.orc as orc + import pandas as pd class upload_file: @@ -18,6 +24,9 @@ def load_file(self): return self.load_csv(self._file) elif self._file.endswith(".json"): return self.load_json(self._file) + elif self._file.endswith(".orc"): + + return self.load_orc(self._file) else: raise ValueError("Unsupported file type") @@ -29,7 +38,12 @@ def load_parquet(self, file): def load_csv(self, file): return csv.read_csv(file, **self._kwargs) - + + def load_orc(self, file): + if os.name == 'nt': + raise ValueError("Unsupported file type for this OS") + else: + return orc.read_table(file, **self._kwargs) #TODO: Use pyarrow.json.read_json() instead of pandas.read_json() def load_json(self, file):