test.csv (251 Bytes)
When I tried to run system.dataset.fromCSV with the attached file on Script Console, it shows ValueError: CSV invalid format: expected #NAMES on line 1 Although the file does content it on line 1. Are there any possible solutions I can try to resolve this issue?
Are you reading the file into a String first, or just passing the file path as the csv
argument?
1 Like
script console (so vison client scope) input:
csvStr = '''#NAMES
Col 1,Col 2,Col 3
#TYPES
I,str,D
#ROWS,6
44,Test Row 2,1.8713151369491254
86,Test Row 3,97.4913421614675
0,Test Row 8,20.39722542161364
78,Test Row 9,34.57127071614745
20,Test Row 10,76.41114659745085
21,Test Row 13,13.880548366871926'''
print system.dataset.fromCSV(csvStr)
csvStr = system.file.readFileAsString('C:\\test.csv')
print system.dataset.fromCSV(csvStr)
Output:
>>>
Dataset [6R ⅹ 3C]
Dataset [6R ⅹ 3C]
>>>
File is fine.
1 Like
I tried covert to string first and then read afterwards, and it works!