wiki:GroupActivities/Meetings/Retreat20151119/Coding

In order to give you some help you can use those commands and/or scripts:

In our case:

  1. File sechiba.f90:

How to get info for column field id:

cat src_sechiba/sechiba.f90 | grep xios_orchidee_send_field | cut -d\" -f2 > fields_id.txt
  1. At src_xml/file_def_orchidee.xml

Python script to extract the columns showned below:

# def xml file 
with open('field_def_orchidee_sechiba.xml', 'r') as content_file:
    data = content_file.readlines()

# contains all ids to search
with open('fields_id.txt', 'r') as cfile:
    fids= cfile.readlines()

# search for all keys
for idf in fids:
    cleanid =  idf.replace('\n','')

    # search for all lines from xml
    for line in data:
        # split lines into array according to " char
        splt = line.split('"')

        # ignore empty lines or those with 1 element
        if splt is None or len(splt) == 1:
            continue
        # replace return carry to nothing
        lineid = line.split('"')[1].replace('\n','')

        # it is mandatory to get the exact match
        if cleanid == lineid:
            # print on screen
            print line.split('"')[NUMBER_TO_CHANGE]

Regarding line:

print line.split('"')[NUMBER_TO_CHANGE]

Replace NUMBER_TO_CHANGE according to those numbers to get the desired colum info:

  • use 3, Output name set in field_def
  • use 5, Long name
  • use 7, Unit in output

For field_def_orchidee_sechiba.xml, it was modified deleting all those non sechiba keys in order to minimize errors. Modify according to your needs.

Once extracted, you can directly paste data into excel page.

Last modified 8 years ago Last modified on 2015-11-10T13:54:06+01:00