Skip to content

Commit

Permalink
Merge pull request #35 from InfluxCommunity/windows
Browse files Browse the repository at this point in the history
Windows
  • Loading branch information
Jayclifford345 authored Jul 11, 2023
2 parents 4c56987 + fe5b689 commit 38e9fcb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Examples/file-import/orc_write.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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:



Expand Down
4 changes: 3 additions & 1 deletion influxdb_client_3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions influxdb_client_3/read_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import pyarrow.csv as csv
import pyarrow.feather as feather
import pyarrow.parquet as parquet
import pyarrow.orc as orc
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:
Expand All @@ -20,6 +25,7 @@ def load_file(self):
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")
Expand All @@ -34,7 +40,10 @@ def load_csv(self, file):
return csv.read_csv(file, **self._kwargs)

def load_orc(self, file):
return orc.read_table(file, **self._kwargs)
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):
Expand Down

0 comments on commit 38e9fcb

Please sign in to comment.