Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

344
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda