Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

347
Visualizações
CSV data with 2 different delimiters for Python 2/Ignition

I am developing the code in Ignition software using Jython/Python 2 scripts. We need to read data from csv file that has two delimiters "," in header and "\t" in data. The code we use are:

file_path = r'T:\test1.csv'
csvData = csv.reader(open(file_path, 'r'))
header = csvData.next() # Skip the fist row
dataset = system.dataset.toDataSet(header,list(csvData))
calcwindow.rootContainer.getComponent('Power Table').data = dataset

After applying this code we get this: Power Table

Question are how can we separate the data so that all rows and columns match with csv.reader as ignition do not support panda or re :(

Update the code and now it separate data correctly:

csvData = csv.reader(open(file_path, 'r'),delimiter=',')
header = csvData.next()# Skip the fist row
for line in csvData:
    str1 = "".join(line) #removes commas
    #print str1
    parts = str1.split("\t")
    print parts
dataset = system.dataset.toDataSet(header,list(parts))
calcwindow.rootContainer.getComponent('Power Table').data = dataset

, but the error code came up:

Row 0 doesn't have the same number of columns as header list.

Any suggestions??

Thanks Igor

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I figure it out myself.

Here is the code:

        file_path = r'T:\test1.csv'
    try:
        file = open(file_path)
        csvData = csv.reader(file,delimiter=',') # open the file with comma delimiter
        header = csvData.next()# Skip the fist row
        csvData1 = list(csvData) # create list from data
        lstLine = csvData1[-1] # selects last line added
        str1 = "".join(lstLine) #removes commas and create string
        parts = str1.split("\t") #split string back into list
        dataset = system.dataset.toDataSet(header,[parts])
        calcwindow.rootContainer.getComponent('Power Table').data = dataset
        file.close()
    except:
        print "CSV busy exporting from TIA software"

Hope it will help anyone.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda