sharing: change csv delimiter
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user