csv delimiter

pull/5/head
florentin.luce 2024-02-14 16:20:04 +01:00
parent 32d8ed626b
commit 3688287e6d
2 changed files with 9 additions and 3 deletions

View File

@ -125,8 +125,14 @@ class VSETB_OT_spreadsheet_from_file(Operator):
filepath = Path(self.filepath)
if filepath.suffix.lower() == '.csv':
with open(filepath, newline=separator) as csvfile:
rows = list(csv.reader(csvfile, delimiter=delimiter))
if len(delimiter) == 1:
with open(filepath, newline=separator) as csvfile:
rows = list(csv.reader(csvfile, delimiter=delimiter))
else: # Auto detect
with open(filepath, 'r', newline="") as csvfile:
dialect = csv.Sniffer().sniff(csvfile.read(1024), delimiters=delimiter)
csvfile.seek(0)
rows = list(csv.reader(csvfile, dialect))
elif filepath.suffix.lower() == '.xlsx':
try:

View File

@ -180,7 +180,7 @@ class SpreadsheetExport(PropertyGroup):
class SpreadsheetImport(PropertyGroup):
#use_custom_cells: BoolProperty(default=False)
separator : StringProperty(default='\\n')
delimiter : StringProperty(default=';')
delimiter : StringProperty(default=',;:')
use_custom_name : BoolProperty(default=False)
custom_name : EnumProperty(items=get_custom_name_items,
description='Use a custom name for asset using a metadata value')