Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from storebrand/release_v1_2_0
Browse files Browse the repository at this point in the history
Update version number
  • Loading branch information
hholgersen authored Nov 28, 2023
2 parents 14e9f9b + 5275d82 commit a25223a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Built with the [Meltano Tap SDK](https://sdk.meltano.com) for Singer Taps.
* `about`
* `stream-maps`
* `schema-flattening`
* `batch`

## Settings

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tap-sharepointsites"
version = "0.0.1"
version = "1.2.0"
description = "`tap-sharepointsites` is a Singer tap for sharepointsites, built with the Meltano Singer SDK."
authors = ["Henning Holgersen"]
keywords = [
Expand Down
10 changes: 0 additions & 10 deletions tap_sharepointsites/file_handlers/csv_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import csv
import logging
import re

LOGGER = logging.getLogger(__name__)

Expand All @@ -15,13 +14,6 @@ def __init__(self, textcontent, delimiter=","):
self.textcontent = textcontent
self.delimiter = delimiter

@staticmethod
def format_key(key):
"""Format key."""
formatted_key = re.sub(r"[^\w\s]", "", key)
formatted_key = re.sub(r"\s+", "_", formatted_key)
return formatted_key.lower()

def get_dictreader(self):
"""Read CSV file and return csv DictReader object for the file."""
dr = csv.DictReader(
Expand All @@ -31,6 +23,4 @@ def get_dictreader(self):
delimiter=self.delimiter,
)

dr.fieldnames = [self.format_key(key) for key in dr.fieldnames.copy()]

return dr
13 changes: 3 additions & 10 deletions tap_sharepointsites/file_handlers/excel_handler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Handle Excel files."""

import logging
import re
import tempfile

import openpyxl
Expand Down Expand Up @@ -36,8 +35,7 @@ def fieldnames(self):
"""Return fieldnames."""
return [c.value for c in self.xlsheet[1]]

@staticmethod
def generator_wrapper(reader):
def generator_wrapper(self, reader):
"""Wrap a reader in a generator."""
header_row = None
for row in reader:
Expand All @@ -50,16 +48,11 @@ def generator_wrapper(reader):
header_cell = header_row[index]

formatted_key = header_cell.value

if not formatted_key:
formatted_key = "" # default to empty string for key

# remove non-word, non-whitespace characters
formatted_key = re.sub(r"[^\w\s]", "", formatted_key)

# replace whitespace with underscores
formatted_key = re.sub(r"\s+", "_", formatted_key)

to_return[formatted_key.lower()] = (
to_return[formatted_key] = (
str(cell.value) if cell.value is not None else ""
)

Expand Down

0 comments on commit a25223a

Please sign in to comment.