sharing: change csv delimiter

This commit is contained in:
Peter Bieringer
2026-02-27 08:31:31 +01:00
parent 99f2472bfa
commit c4e2c49050
2 changed files with 4 additions and 4 deletions

View File

@@ -948,7 +948,7 @@ class BaseSharing:
answer_array.append(key + '=' + str(answer[key]))
if 'Content' in answer and answer['Content'] is not None:
csv = io.StringIO()
writer = DictWriter(csv, fieldnames=DB_FIELDS_V1)
writer = DictWriter(csv, fieldnames=DB_FIELDS_V1, delimiter=';')
if output_format == "csv":
writer.writeheader()
for entry in answer['Content']:
@@ -959,7 +959,7 @@ class BaseSharing:
index = 0
for line in csv.getvalue().splitlines():
# create a shell array with content lines
answer_array.append('Content[' + str(index) + ']="' + line + '"')
answer_array.append('Content[' + str(index) + ']="' + line.replace('"', '\\"') + '"')
index += 1
headers = {
"Content-Type": "text/csv"

View File

@@ -509,7 +509,7 @@ class Sharing(sharing.BaseSharing):
logger.debug("sharing database load begin: %r", file)
with self._storage.acquire_lock("r", None):
with open(file, 'r', newline='') as csvfile:
reader = csv.DictReader(csvfile, fieldnames=sharing.DB_FIELDS_V1)
reader = csv.DictReader(csvfile, fieldnames=sharing.DB_FIELDS_V1, delimiter=';')
self._lines = 0
for row in reader:
# logger.debug("sharing database load read: %r", row)
@@ -542,6 +542,6 @@ class Sharing(sharing.BaseSharing):
def _write_csv(self, file: str) -> bool:
with open(file, 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=sharing.DB_FIELDS_V1)
writer = csv.DictWriter(csvfile, fieldnames=sharing.DB_FIELDS_V1, delimiter=';')
writer.writerows(self._sharing_cache)
return True