Skip to content

Commit

Permalink
YDA-5585: support windows-formatted csvs
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox committed Jan 31, 2024
1 parent 3706218 commit 76ad831
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions unit-tests/files/windows-csv.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
category,subcategory,groupname,manager,member,schema_id
testcsv,testcsv,csvupload1,manager,member,default-3
testcsv,testcsv,csvupload2,manager,member,default-3
3 changes: 3 additions & 0 deletions unit-tests/test_importgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def test_parse_csv(self):
args = {"offline_check": True}
parse_csv_file("files/csv-import-test.csv", args, "1.9")

# With carriage returns
parse_csv_file("files/windows-csv.csv", args, "1.9")

@patch('sys.stderr', new_callable=StringIO)
def test_parse_csv_with_header_suffixes(self, mock_stderr):
args = {"offline_check": True}
Expand Down
5 changes: 3 additions & 2 deletions yclienttools/importgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,12 @@ def parse_csv_file(input_file, args, yoda_version):
row_number += 1
d = {}
for j in range(len(line)):
if len(line[j]):
item = line[j].strip()
if len(item):
if header[j] not in d:
d[header[j]] = []

d[header[j]].append(line[j])
d[header[j]].append(item)

rowdata, error = _process_csv_line(d, args, yoda_version)

Expand Down

0 comments on commit 76ad831

Please sign in to comment.