I am using this script mishmashed from posts on this forum/IA's csv info page , and it almost works the way I need it too , but I need help with how its imported
##importing from 2 libraries
from StringIO import StringIO
import csv
grabbedfile = event.file.getString("UTF-8")
Headers = ["Feature","X","Y","Z","i","j","k","DIA"]
#this is the empty list
CsvData = []
#this is the grabbed file stored in strings in lists , per row
StringLists = [row for row in csv.reader(StringIO(grabbedfile))]
for inner_list in StringLists:
for element in inner_list:
#put it in the empty list
CsvData.append(element)
#this prints the list as a whole
#system.perspective.print(CsvData)
#split into groups of 8
ListGroups = zip(*(iter(CsvData),) * 8)
#system.perspective.print(ListGroups)
tagpath = "CSVData" ##tag I am putting the data in
ds = system.dataset.toDataSet(Headers,ListGroups)
system.tag.writeBlocking(tagpath,ds)## this line is shoving all the data into the above tag
FileNametagpath = "FileName" ##tag I am putting the data in
FileName = event.file.name
system.tag.writeBlocking(FileNametagpath,FileName)
the problem I am having is that the CSVs I am importing from a machine are in a weird format
the columns will look like
Name,1,2,3,4,5,6,(Blank)
Name,1,2,3,4,5,6,(Blank)
Name,1,2,3,4,5,6,(Blank)
Name,1,2,3,4,5,6,(Blank)
Name,1,2,3,4,5,6,7
Name,1,2,3,4,5,6,(Blank)
Name,1,2,3,4,5,6,(Blank)
Name,1,2,3,4,5,6,7
because the 8th column doesnt have any values in it until later on , everytime I import it offsets all of the values from the next rows and starts making a mess out of the system going on afterwards
I have been getting around this by just entering any value into the first row and the 8th column in the csv before I import it , but it would be nicer if I could just drag and drop the CSVs without having to do this everytime. Is there anyway to make it act like there is 8 columns even if the first row only has 7 values?