Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Licensed under the MIT license.
import csv
import logging
import json
import ast

from redis.commands.graph.query_result import QueryResult

Expand All @@ -21,6 +23,8 @@ def _to_csv_format(val: any) -> str:
return str(val).lower()
if str(val) == 'True' or str(val) == 'False':
return str(val).lower()
if str(val).startswith('{') and str(val).endswith('}'):
return json.dumps(ast.literal_eval(str(val)))
return str(val)

@staticmethod
Expand All @@ -45,7 +49,7 @@ def write_twin_data(export_dir: str, file_name: str, query_result: QueryResult,
output_file_name = f'{export_dir}/{file_name}.csv'
logger.debug(f"Writing CSV file {output_file_name}")
with open(output_file_name, 'w') as csvfile:
csv_writer = csv.DictWriter(csvfile, fieldnames=headers, delimiter=delimiter, quotechar=quote_char, quoting=csv.QUOTE_ALL)
csv_writer = csv.DictWriter(csvfile, fieldnames=headers, delimiter=delimiter, quotechar=quote_char, quoting=csv.QUOTE_MINIMAL)
csv_writer.writeheader()
csv_writer.writerows(rows)
logger.debug(f"... CSV file {output_file_name} has been written")
Expand All @@ -64,7 +68,7 @@ def write_relationship_data(export_dir: str, file_name: str, query_result: Query
output_file_name = export_dir + file_name + '.csv'
logger.debug(f"Writing CSV file {output_file_name}")
with open(output_file_name, 'w') as csvfile:
csv_writer = csv.DictWriter(csvfile, fieldnames=headers, delimiter=delimiter, quotechar=quote_char, quoting=csv.QUOTE_ALL)
csv_writer = csv.DictWriter(csvfile, fieldnames=headers, delimiter=delimiter, quotechar=quote_char, quoting=csv.QUOTE_MINIMAL)
csv_writer.writeheader()
csv_writer.writerows(rows)
logger.debug(f"... CSV file {output_file_name} has been written")
2 changes: 1 addition & 1 deletion CosmoTech_Acceleration_Library/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) Cosmo Tech corporation.
# Licensed under the MIT license.

__version__ = '0.2.15'
__version__ = '0.2.16'