sharing: change csv delimiter
This commit is contained in:
@@ -948,7 +948,7 @@ class BaseSharing:
|
|||||||
answer_array.append(key + '=' + str(answer[key]))
|
answer_array.append(key + '=' + str(answer[key]))
|
||||||
if 'Content' in answer and answer['Content'] is not None:
|
if 'Content' in answer and answer['Content'] is not None:
|
||||||
csv = io.StringIO()
|
csv = io.StringIO()
|
||||||
writer = DictWriter(csv, fieldnames=DB_FIELDS_V1)
|
writer = DictWriter(csv, fieldnames=DB_FIELDS_V1, delimiter=';')
|
||||||
if output_format == "csv":
|
if output_format == "csv":
|
||||||
writer.writeheader()
|
writer.writeheader()
|
||||||
for entry in answer['Content']:
|
for entry in answer['Content']:
|
||||||
@@ -959,7 +959,7 @@ class BaseSharing:
|
|||||||
index = 0
|
index = 0
|
||||||
for line in csv.getvalue().splitlines():
|
for line in csv.getvalue().splitlines():
|
||||||
# create a shell array with content lines
|
# create a shell array with content lines
|
||||||
answer_array.append('Content[' + str(index) + ']="' + line + '"')
|
answer_array.append('Content[' + str(index) + ']="' + line.replace('"', '\\"') + '"')
|
||||||
index += 1
|
index += 1
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "text/csv"
|
"Content-Type": "text/csv"
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ class Sharing(sharing.BaseSharing):
|
|||||||
logger.debug("sharing database load begin: %r", file)
|
logger.debug("sharing database load begin: %r", file)
|
||||||
with self._storage.acquire_lock("r", None):
|
with self._storage.acquire_lock("r", None):
|
||||||
with open(file, 'r', newline='') as csvfile:
|
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
|
self._lines = 0
|
||||||
for row in reader:
|
for row in reader:
|
||||||
# logger.debug("sharing database load read: %r", row)
|
# logger.debug("sharing database load read: %r", row)
|
||||||
@@ -542,6 +542,6 @@ class Sharing(sharing.BaseSharing):
|
|||||||
|
|
||||||
def _write_csv(self, file: str) -> bool:
|
def _write_csv(self, file: str) -> bool:
|
||||||
with open(file, 'w', newline='') as csvfile:
|
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)
|
writer.writerows(self._sharing_cache)
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user